电子邮件发送c#应用程序 [英] Email sending c# application
问题描述
大家好,
我在c#应用程序中有一个发送邮件功能。
以下是我用来发送电子邮件的代码 -
Hi All,
I am having an send email functionality in c# application.
Following is the code I am using to send email -
public static bool SendMail(string toList, string from, string ccList, string subject, string body)
{
bool flag = false;
MailMessage message = new MailMessage();
SmtpClient smtpClient = new SmtpClient();
string msg = string.Empty;
try
{
MailAddress fromAddress = new MailAddress(from);
message.From = fromAddress;
message.To.Add(toList);
if (ccList != null && ccList != string.Empty)
message.CC.Add(ccList);
message.Subject = subject;
message.IsBodyHtml = true;
message.Body = body;
smtpClient.Host = "smtp.compName.org";
smtpClient.Port = 587;
smtpClient.EnableSsl = false;
smtpClient.UseDefaultCredentials = true;
smtpClient.Credentials = new System.Net.NetworkCredential(UserName,Password);
smtpClient.Send(message);
flag = true;
}
catch (Exception ex)
{
msg = ex.Message;
}
return flag;
}
我使用8个月以上的相同功能。突然发生了什么,我不明白。
我没有从我的应用程序收到任何电子邮件。它有日志条目 - 邮件发送成功。
没有任何例外。
从上面的代码中我评论了 message.IsBodyHtml = true; 这一行我正在收到电子邮件,但它的HTML代码。
有什么问题我不理解!!!
我正在使用网络解决方案服务发送电子邮件。
请尽快推荐。
提前感谢您的建议。
问候,
Avinash
I am using the same function from more than 8 months. Suddenly what happens I didn't understand.
I am not getting any emails from my applications. It has log entries - Mail sent successfully.
There is no any exception.
From above code I have commented message.IsBodyHtml = true; this line and I am getting emails but its html code.
What is the problem I am not understanding!!!
I am using network solutions service to send email.
Please suggest , ASAP.
Thanks for your suggestions in advance.
Regards,
Avinash
推荐答案
我使用的服务提供商的问题,之后与他们交谈后才知道网络邮件服务器已关闭,发送邮件功能没问题。
The problem with the service provider which I am using, after talking with them came to know that the web mail server was down , no problem with send mail functionality.
这篇关于电子邮件发送c#应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!