C# Exchange发送邮件
https://www.cnblogs.com/gcczhongduan/p/4025106.html 原博客地址,亲测可用.
帮助需要公司内部使用Exchange发送邮件功能的同学.完成简单的以下两步.
1.安装Microsoft.Exchange.WebServices,可直接通过Nuget包安装.
2.样例代码如下
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
using Microsoft.Exchange.WebServices; using Microsoft.Exchange.WebServices.Data; private void SendEmail() { ExchangeService service = new ExchangeService(); // 获取身份验证, 能够尝试你的邮箱名, 域用户ID等 // user: 登录username,邮箱登录ID或者域登录ID // password:你懂的 // domain:域,不是域名,域用户的的话就得填这个,选填 service.Credentials = new NetworkCredential("user", "password", "domain"); service.TraceEnabled = true; service.AutodiscoverUrl("zhangsan@yuming.com"); // 这个是发件人的邮箱地址,完整的(xx@dd.com). EmailMessage message = new EmailMessage(service); message.Subject = "Email的主题"; message.Body = "Email的内容"; message.ToRecipients.Add("收件人的邮件地址"); message.Save(); message.SendAndSaveCopy();// 发送 }