我有一个交换账户。我需要发一封电子邮件。我尝试使用SmtpClient发送它失败了。谷歌搜索后我几乎没有问题
任何想法?
这是我的代码。我认为这不能用SMTP完成。
MailMessage mailMessage = new MailMessage();
mailMessage.From = new MailAddress("sender@domain.com", "Sender");
mailMessage.To.Add("receiver@domain.com");
mailMessage.Subject = "Test Exchange Email";
mailMessage.Body = "Sameple test message";
SmtpClient smtp = new SmtpClient("Exchange Server Url");
smtp.EnableSsl = true;
smtp.Port = 465;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("username", "pwd");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(mailMessage);