[英]Sending emails are not received outside the company using System.Net.Mail
[英]Sending mail using { System.Net.Mail }
SmtpClient client = new SmtpClient();
client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
client.Timeout = 10000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("*********@gmail.com", "***********");
MailMessage mm = new MailMessage("*********@gmail.com", "******@gmail.com", "delivery.", "tttt");
mm.BodyEncoding = UTF8Encoding.UTF8;
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
Attachment fMailAttachment;
fMailAttachment = new Attachment(FilePath);
mm.Attachments.Add(fMailAttachment);
client.Send(mm);
mm.Attachments.Dispose();
我正在尝试使用此代码发送电子邮件。 它运作良好,但仅当我登录我的邮件并使其打开时,当我关闭邮件时,它不会发送任何邮件。
该代码有什么问题?
在我编辑client.Timeout = 10000之后,它工作良好。 到client.Timeout = 100000;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.