发送邮件(使用SMTP.office365.com)错误 [英] Send Mail (using SMTP.office365.com) error
问题描述
以下是我使用smtp.outlook365.com发送电子邮件的代码, 我收到以下错误消息-
消息="无法从传输连接读取数据:net_io_connectionclosed. "
是什么原因导致此错误?
--- ****************************************
string smtpClient =(string)Dts.Variables ["$ Project :: SmtpConnectionString"].Value;
字符串smtpPort =(string)Dts.Variables ["$ Project :: SmtpPort"].Value;
字符串smtpUserName =(string)Dts.Variables ["$ Project :: SMTPUsername"].Value;
字符串smtpPwd = Dts.Variables ["$ Project :: SMTPPassword"].GetSensitiveValue().ToString();
字符串mailFrom =(string)Dts.Variables ["$ Project :: EmailFrom".Value;
字符串mailTo =(string)Dts.Variables ["$ Project :: EmailTo"].Value;
字符串mailCc =(string)Dts.Variables ["$ Project :: EmailCc"].Value;
字符串dbServer =(string)Dts.Variables ["$ Project :: OSEDBServer"].Value;
字符串dbName =(string)Dts.Variables ["$ Project :: OSEDBName"].Value;
字符串mailSubject ="Some Subject";
字符串mailBody ="Some Body Text";
MailMessage邮件=新的MailMessage();
SmtpClient SmtpServer =新的SmtpClient(smtpClient);
mail.From = new MailAddress(mailFrom);
mail.To.Add(mailTo);
mail.CC.Add(mailCc);
mail.Subject = mailSubject;
mail.Body = mailBody;
mail.Priority = MailPriority.Normal;
SmtpServer.Host ="smtp.office365.com";
SmtpServer.Port = Int32.Parse(smtpPort); //已经尝试了587、25和
SmtpServer.Credentials =新的System.Net.NetworkCredential(smtpUserName,smtpPwd);
SmtpServer.EnableSsl = true;
SmtpServer.TargetName = smtpClient;
SmtpServer.Send(mail);
嗨.
看看我的帖子...
http://zsvipullo.blogspot.it/2015/01 /send-e-mail-message-using-office365.html
我用了这个
SmtpClient smtp =新的System.Net.Mail.SmtpClient("outlook.office365.com");
Below is my code for sending email using smtp.outlook365.com , I get the following error message -
"Message = "Unable to read data from the transport connection: net_io_connectionclosed." "
What is causing this error ?
---***********************************
string smtpClient = (string)Dts.Variables["$Project::SmtpConnectionString"].Value;
string smtpPort = (string)Dts.Variables["$Project::SmtpPort"].Value;
string smtpUserName = (string)Dts.Variables["$Project::SMTPUsername"].Value;
string smtpPwd = Dts.Variables["$Project::SMTPPassword"].GetSensitiveValue().ToString();
string mailFrom = (string)Dts.Variables["$Project::EmailFrom"].Value;
string mailTo = (string)Dts.Variables["$Project::EmailTo"].Value;
string mailCc = (string)Dts.Variables["$Project::EmailCc"].Value;
string dbServer = (string)Dts.Variables["$Project::OSEDBServer"].Value;
string dbName = (string)Dts.Variables["$Project::OSEDBName"].Value;
string mailSubject = "Some Subject";
string mailBody = "Some Body Text";
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient(smtpClient);
mail.From = new MailAddress(mailFrom);
mail.To.Add(mailTo);
mail.CC.Add(mailCc);
mail.Subject = mailSubject;
mail.Body = mailBody;
mail.Priority = MailPriority.Normal;
SmtpServer.Host = "smtp.office365.com";
SmtpServer.Port = Int32.Parse(smtpPort); //Have tried both 587 , 25
SmtpServer.Credentials = new System.Net.NetworkCredential(smtpUserName, smtpPwd);
SmtpServer.EnableSsl = true;
SmtpServer.TargetName = smtpClient;
SmtpServer.Send(mail);
Hi.
Have a look at my post...
http://zsvipullo.blogspot.it/2015/01/send-e-mail-message-using-office365.html
I used this
SmtpClient smtp = new System.Net.Mail.SmtpClient("outlook.office365.com");
这篇关于发送邮件(使用SMTP.office365.com)错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!