我的Outlook可以使用我的帐户设置发送电子邮件。 但我无法从C#发送电子邮件。
以下是我的帐户设置:
Microsoft exchange server: exch.server1.com;
User name: user1@server1.com;
Password: password1;
-----安全选项卡-----
Encrypt data between Microsoft Office Outlook and Microsoft Exchange - CHECKED;
Logon network security: Negotiate Authentication;
-----连接标签-----
Connect using my Local Area Network (LAN) - SELECTED;
Connect to Microsoft Exchange using HTTP - CHECKED;
-----交换代理设置表格-----
Use this email to connect to my proxy server fo Exchange: https://owa.server1.com
Connect using SSL only - CHECKED;
Only connect to proxy servers that have this principal name in their certificate: msstd:owa.server1.com;
Proxy authentication settings: NTLM Authentication;
这是我的C#代码:
var completeMessage = new MailMessage();
completeMessage.From = new MailAddress("ivanov@server1.com");
completeMessage.To.Add("ivanov@server1.com");
completeMessage.Subject = "test subject";
completeMessage.Body ="test body";
var client = new SmtpClient("exch.server1.com");
client.Credentials = new NetworkCredential("user1@server1.com", "password1");
client.Send(completeMessage);
发生以下异常:
The remote name could not be resolved: 'exch.server1.com'
此网址“exch.server1.com”已被我的办公室封锁。 请告诉我如何配置SmtpClient来发送电子邮件。