We are testing the new Office 365 beta, and i have a mail account on the Exchange Online service. Now I'm trying to connect a LOB application that can send smtp emails from my test account.
However the Exchange 365 platform requires TLS encryption on port 587, and there is a 'feature' of System.Net.Mail
that does not permit Implicit SSL encryption.
Has anyone managed to get C# sending mails via this platform?
I have the following basic code that should send the mail - any advice would be appreciated.
SmtpClient server = new SmtpClient("ServerAddress");
server.Port = 587;
server.EnableSsl = true;
server.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
server.Timeout = 5000;
server.UseDefaultCredentials = false;
MailMessage mail = new MailMessage();
mail.From = new MailAddress("recipent@anyaddress");
mail.To.Add("[email protected]");
mail.Subject = "test out message sending";
mail.Body = "this is my message body";
mail.IsBodyHtml = true;
server.Send(mail);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…