我刚刚迁移了一个ASP.NET 4应用程序,该应用程序从Win Server 2008 R2发送电子邮件附件到2012.我使用Visual Studio 2010,当我调试项目工作时,我收到带有附件的电子邮件但这是通过localhost。我在web.config中的smtp设置中使用了pod51008.outlook.com帐户,但我无法通过电子邮件发送该帐户。从技术上讲,我可以访问URL并登录。一旦我登录,我应该能够点击按钮并按说明发送带有附件的电子邮件到我的用户帐户,但我收到了用户定义的错误消息。
这是web.config文件:
<system.net>
<mailSettings>
<smtp from="online_account@domain.org">
<network host="pod51008.outlook.com" port="587" userName="online_account@domain.org" password="password" enableSsl="true" />
</smtp>
</mailSettings>
这是电子邮件子程序代码:
Private Sub email(ByVal att As String)
Try
Dim sendfrom As MailAddress = New MailAddress("online_account@domain.org", "Email with attachment")
Dim sendto As MailAddress = New MailAddress(EMP.Email)
Dim attachmentFile As New Attachment(att)
Dim mymessage As New MailMessage(sendfrom, sendto)
With mymessage
.Subject = "Email with attachment "
.Body = "<br/></br/> Email message"
.Attachments.Add(attachmentFile)
.IsBodyHtml = True
End With
Dim smtpclient As New SmtpClient()
smtpclient.EnableSsl = True
smtpclient.Send(mymessage)
Catch ex As Exception
errormsg.Text = "Error Sending Email, please contact Help Desk"
End Try
errormsg.Text = "<div align='center'>An email has been sent to " & EMP.User_Email & ".</div><br/>"
End Sub
在Win Server 2012中启用了SMTP我不认为我需要这个,因为我使用Outlook帐户发送电子邮件(如果我错了,请纠正我)。至少就是我在Win 2008 R2中使用它的方式,这是正常的。
我一直在寻找各处,但我能找到在服务器内测试SMTP配置的地方。 任何帮助将不胜感激!