发送邮件时出错。 [英] Error while sending mail.

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

问题描述

您好,



我想通过我的网站发送电子邮件。代码在几天内完美运行,邮件发送成功。现在它正在给出smtpexception未被发送邮件的用户代码失败处理。

我使用过此代码

Hello,

I want to send email through my website. The code was working perfectly in few days and the mail was send successfully. Now it is giving "smtpexception was unhandled by user code failure sending mail".
I have used this code

try
{
    MailMessage Msg = new MailMessage();
    // Sender e-mail address.
    Msg.From = new MailAddress(tbx_emailId.Text);
    // Recipient e-mail address.
    Msg.To.Add("email address to be send ");
    Msg.Subject = "Message";
    string body = " Name: " + Name + " ";
    body += "Email: " + Email + " ";
    body += "Phone : " + Phone + " ";
    body += "Subject:" + Subject + " ";
    body += "Comments: " + Comments + " ";
    Msg.Body = body;



    // your remote SMTP server IP.
    SmtpClient smtp = new SmtpClient();
    smtp.Host = "smtp.gmail.com";
    smtp.Port = 587;
    smtp.Credentials = new System.Net.NetworkCredential("yourgamil@gmail.com", "gmail password");
    smtp.EnableSsl = true;
    smtp.Send(Msg);
    //Msg = null;
    lbl_msg.Text = "Thankyou for sending inquiry";

}
catch (Exception ex)
{
    Console.WriteLine("{0} Exception caught.", ex);
}



请帮我解决这个问题...

谢谢。


Please help me to solve this...
Thank you.

推荐答案

http: //www.c-sharpcorner.com/UploadFile/9f0ae2/send-emails-with-attachment-in-Asp-Net/ [ ^ ]



访问此链接....
http://www.c-sharpcorner.com/UploadFile/9f0ae2/send-emails-with-attachment-in-Asp-Net/[^]

visit this link....


希望这会对您有所帮助

http://stackoverflow.com/questions/2588389/smtpexception-was-unhandled-by-user-code [ ^ ]
hope this will help you
http://stackoverflow.com/questions/2588389/smtpexception-was-unhandled-by-user-code[^]


检查文章..

smtpexception-was-unhandled-by-user-code [ ^ ]
Check the article..
smtpexception-was-unhandled-by-user-code[^]


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

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