[英]Sending emails are not received outside the company using System.Net.Mail
我正在使用以下代码来发送电子邮件。 电子邮件在工作中已成功接收到收件人,但未在外部接收。 我试图将电子邮件发送到我的gmail帐户,但同样的问题,但我收不到。 在工作中,我们使用的是Exchange2010。我检查了gmail中的垃圾邮件,未发现电子邮件。
我的代码:
public bool SendEmail()
{
try
{
var mailMessage = CreateMailMessage();
var client = new SmtpClient()
{
Credentials = new NetworkCredential(Resources.Username, Resources.Password, Resources.Domain),
Port = 25,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Host = ConfigurationProperties.ExchangeIPAddress
};
client.Send(mailMessage);
}
catch (Exception ex)
{
LogFile.Write(string.Format("EmailManager::SendEmail failed at {0}", DateTime.Now.ToLongTimeString()));
LogFile.Write(string.Format("Error: {0}", ex.Message));
return false;
}
return true;
}
private MailMessage CreateMailMessage()
{
var mailMessage = new MailMessage();
mailMessage.Subject = ConfigurationProperties.EmailSubject;
mailMessage.Body = ConfigurationProperties.EmailBody;
mailMessage.IsBodyHtml = true;
mailMessage.BodyEncoding = Encoding.UTF8;
mailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
LogFile.Write(string.Format("Subject= {0}", mailMessage.Subject));
LogFile.Write(string.Format("Body= {0}", mailMessage.Body));
AddRecipients(mailMessage);
return mailMessage;
}
为了让外部电子邮件的收件人接收电子邮件,我是否缺少任何财产?
没有可以设置为允许邮件发送到网络之外的属性。 这听起来像Exchange服务器上的配置,与System.Net.Mail无关。
您需要与系统管理员联系。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.