发送失败邮件发生错误 [英] sending failure mail error occurs

查看:114
本文介绍了发送失败邮件发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下代码中发生发送失败邮件错误
代码有什么问题

sending failure mail error occurs in following code
whats wrong in the code

public void Sendemail()
        {
            string ActivationUrl;

            try
            {

                MailMessage message = new MailMessage();

                message.From = new MailAddress("XXXX@gmail.com ");

                message.To.Add(txtemail.Text);

                message.Subject = "Verification Email";

                ActivationUrl = Server.HtmlEncode("HIII");                

                message.IsBodyHtml = true;

               message.Body = "<a href="" activationurl="">Click Here to verify your acount</a>";

                
                SmtpClient smtp = new SmtpClient();

                smtp.Credentials = new System.Net.NetworkCredential("XXXX@gmail.com", "XXXX");

                smtp.Host = "mail.gmail.com";

                smtp.Port = 587;

                smtp.EnableSsl = true;

            smtp.Send(message);// on this line error occur
            }

            catch (Exception)
            {
                throw;
            }
        }

推荐答案

检查以下CP提示;
从Yahoo!,GMail,Hotmail(C#)发送电子邮件 [ ^ ]
请注意,gmail smtp servrr是 smtp.gmail.com
最好在发布问题时添加错误的完整堆栈跟踪.
check below CP Tip;
Send Email from Yahoo!, GMail, Hotmail (C#)[^]
Note that gmail smtp servrr is smtp.gmail.com
it is better to add full stack trace of the error when you post question.
报价:

发生发送失败邮件错误


上面的内容不会提供任何有关问题原因的线索,或者您会在哪一行收到此错误等信息.
遵循上述CP技巧并进行相应的更改,仍然会收到错误,单击答案下方的改进问题"链接,并添加错误的完整堆栈跟踪详细信息和更新的代码.


above will not give any clue on what was the reason for the issue or which line you get this error etc..
follow above CP tip and do the changes accordingly, still you receive errors, click on improve question link below the answer and add full stack trace details of the error and updated code.


这篇关于发送失败邮件发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆