我想写将通过我的Exchange Server 2010的 发送电子邮件代码和我得到这个错误:C#发送电子邮件通过Exchange服务器2010
An unhandled exception of type 'System.Security.Authentication.AuthenticationException' occurred in System.dll
我证实了我的Exchange服务器上发送匿名电子邮件,我所有的信息都是正确的(IP,端口,用户名和密码)。
但仍无法发送。
这里是我使用C#代码:
SmtpClient client = new SmtpClient();
client.Port = 25;
client.Host = "myip";
client.EnableSsl = true;
client.Timeout = 10000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("username", "password");
MailMessage mm = new MailMessage("myEmail", "SendToEmail", "test","test");
mm.BodyEncoding = UTF8Encoding.UTF8;
mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
client.Send(mm);
感谢您的帮助!
嘿,感谢您的回复我做的权利,我现在使用Exchange Web服务API(EWS)。现在我得到这个错误:在Microsoft.Exchange.WebServices.dll中发生未经处理的类型为“Microsoft.Exchange.WebServices.Data.ServiceRequestException”的异常,并且它表示与我的TLS/SSL有关。等待你的帮助谢谢你! – Yahav
您使用Exchange名称吗?或者IP地址打到交换机?我相信尝试将它切换到另一个您目前没有使用的版本,因为大多数证书都与名称相关,而不是服务器的IP地址,因此请尝试切换。我希望它有帮助。 –