[ad_1]
私は例外を下回っています
while sending mail in c# Error in processing. The server response was: 5.7.3 STARTTLS is required to send mail [MR2P264CA0029.FRAP264.PROD.OUTLOOK.COM] What I have tried: Code used to send mail updated as below: web.config <pre> <add key="AdminEmail" value="alexander.junior@test.com"/> <add key="SMTPServer" value="smtp.office365.com"/> <add key="SMTPServerPort" value="587"/>
MailMessage objMailMsg = new MailMessage(); MailAddress fromAddress = new MailAddress(Common.FromMail); SmtpClient smtpClient = new SmtpClient(); int port = Common.SMTPPort; string FileName = Common.EMAIL_FILE_PATH+objEmail.AttachedFileName; string IPaddr = Common.SMTPServer; objMailMsg.From = fromAddress; string[] Toarray = objEmail.ToEmailId.Split(','); foreach (string ToAddress in Toarray) { if (ToAddress.Trim() != string.Empty) objMailMsg.To.Add(ToAddress.Trim()); } if (objEmail.CCEmailId != null && objEmail.CCEmailId.Length > 0) { string[] Ccarray = objEmail.CCEmailId.Split(','); foreach (string CcAddress in Ccarray) { if(CcAddress.Trim()!= string.Empty) objMailMsg.CC.Add(CcAddress.Trim()); } } char[] chrDelim = new char[] { ',' }; foreach (string strSubstr in FileName.Split(chrDelim)) { if (File.Exists(strSubstr)) { Attachment objAttachment = new Attachment(strSubstr); objMailMsg.Attachments.Add(objAttachment); } } objMailMsg.Subject = objEmail.EmailSubject; objMailMsg.Body = objEmail.EmailBody; objMailMsg.IsBodyHtml = true; if (port == 0) { port = 25; } Common.WriteDDSLog("Email Sent :-"+FileName); smtpClient.Port = port; smtpClient.Host = IPaddr; smtpClient.Send(objMailMsg);
解決策 1
解決策 2
SSLではなく、TLSが必要です。
上記の解決策では機能しませんでした
[ad_2]
コメント