System.Net.Mail.MailMessage“回复”标头在 IIS 6.0 中被忽略,但在 IIS 5.1 中正常
我有一个在 WinXP 计算机 (IIS 5.1) 上开发和单元测试的 Web 应用程序项目。它已发布到Win2003Server (IIS 6.0)。该应用程序的一项功能会发送一封带有“回复”标题的电子邮件(下面是片段)。在 IIS 5.1 计算机上,回复正确显示在标头中。从 IIS 6.0 PC 发送时,标头不包含回复地址(见下文):
Public Shared Sub SendEmail_withReplyTo(ByVal emailfrom As String, _
ByVal emailto As String, _
ByVal vbody As String, _
ByVal vsubject As String, _
ByVal msgcc As String, _
ByVal msgbcc As String, _
ByVal sReplyTo As String)
Dim MyMsg As New MailMessage
ErrorTrap.ErrorMsg = Nothing
With MyMsg
.From = New MailAddress(emailfrom)
.Headers.Add("Reply-To", sReplyTo)
.To.Add(emailto)
If msgcc.Length > 0 Then
.CC.Add(msgcc)
End If
If msgbcc.Length > 0 Then
.Bcc.Add(msgbcc)
End If
.Subject = vsubject
.IsBodyHtml = True
.Body = vbody
End With
Try
Dim smtp As New SmtpClient
smtp.Send(MyMsg)
Catch ex As Exception
ErrorTrap.ErrorMsg = Nothing
ErrorTrap.ErrorMsg = ex.ToString
End Try
End Sub
以下互联网标头是从 MS Outlook 2003 - 查看 - 选项粘贴的:
有效回复-从 JOHNXP 机器(带有 IIS 5.1 的开发 PC)发送的收件人:
Return-path: <[email protected]>
Received: from JohnXP (unverified [10.10.30.66]) by mail.cbmiweb.com
(Rockliffe SMTPRA 9.2.0) with ESMTP id <[email protected]>;
Mon, 28 Jun 2010 15:16:25 -0400
Message-ID: <[email protected]>
Reply-To: [email protected]
MIME-Version: 1.0
From: [email protected]
To: [email protected]
Date: 28 Jun 2010 15:17:57 -0400
Subject: Regarding your Ad #153949: Yard sale in vienna va June 12 at 8am
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
缺少回复-从 MOJITO 机器(带有 IIS 6.0 的 2003 服务器)发送的收件人:
Return-path: <[email protected]>
Received: from MOJITO (unverified [10.10.30.14]) by mail.cbmiweb.com
(Rockliffe SMTPRA 9.2.0) with ESMTP id <[email protected]>;
Mon, 28 Jun 2010 13:37:53 -0400
Message-ID: <[email protected]>
MIME-Version: 1.0
From: [email protected]
To: [email protected]
Date: 28 Jun 2010 13:39:25 -0400
Subject: Regarding your Ad #153949: Yard sale in vienna va June 12 at 8am
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
我什至设置了Win2003 计算机上的 VStudio2008 并在上面代码内的断点处停止,以确保邮件消息实际上已正确构建,并将“Reply-To”添加到标头(确实如此)。然而,当到达 Outlook 时,来自 MOJITO 服务器的邮件在标头中缺少“回复”。
是否存在其他配置问题会阻碍实际代码尝试执行的操作?
I have a web app project developed and unit-tested on a WinXP machine (IIS 5.1). It has been published to a Win2003Server (IIS 6.0). One feature of the app sends an email with a "Reply-To" header (snippet follows). On the IIS 5.1 machine, the Reply-To appears properly in the header. When sent from the IIS 6.0 PC, the header does not contain the Reply-To address (see below):
Public Shared Sub SendEmail_withReplyTo(ByVal emailfrom As String, _
ByVal emailto As String, _
ByVal vbody As String, _
ByVal vsubject As String, _
ByVal msgcc As String, _
ByVal msgbcc As String, _
ByVal sReplyTo As String)
Dim MyMsg As New MailMessage
ErrorTrap.ErrorMsg = Nothing
With MyMsg
.From = New MailAddress(emailfrom)
.Headers.Add("Reply-To", sReplyTo)
.To.Add(emailto)
If msgcc.Length > 0 Then
.CC.Add(msgcc)
End If
If msgbcc.Length > 0 Then
.Bcc.Add(msgbcc)
End If
.Subject = vsubject
.IsBodyHtml = True
.Body = vbody
End With
Try
Dim smtp As New SmtpClient
smtp.Send(MyMsg)
Catch ex As Exception
ErrorTrap.ErrorMsg = Nothing
ErrorTrap.ErrorMsg = ex.ToString
End Try
End Sub
The following internet headers are pasted from MS Outlook 2003 - View - Options:
Valid Reply-To as sent from JOHNXP machine (the dev PC with IIS 5.1):
Return-path: <[email protected]>
Received: from JohnXP (unverified [10.10.30.66]) by mail.cbmiweb.com
(Rockliffe SMTPRA 9.2.0) with ESMTP id <[email protected]>;
Mon, 28 Jun 2010 15:16:25 -0400
Message-ID: <[email protected]>
Reply-To: [email protected]
MIME-Version: 1.0
From: [email protected]
To: [email protected]
Date: 28 Jun 2010 15:17:57 -0400
Subject: Regarding your Ad #153949: Yard sale in vienna va June 12 at 8am
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Missing Reply-To as sent from the MOJITO machine (the 2003 server with IIS 6.0):
Return-path: <[email protected]>
Received: from MOJITO (unverified [10.10.30.14]) by mail.cbmiweb.com
(Rockliffe SMTPRA 9.2.0) with ESMTP id <[email protected]>;
Mon, 28 Jun 2010 13:37:53 -0400
Message-ID: <[email protected]>
MIME-Version: 1.0
From: [email protected]
To: [email protected]
Date: 28 Jun 2010 13:39:25 -0400
Subject: Regarding your Ad #153949: Yard sale in vienna va June 12 at 8am
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
I even set up VStudio2008 on the Win2003 machine and stopped at a breakpoint inside the code above to make sure that the mailmessage was in fact being correctly built with the "Reply-To" added to the header (it is). Yet when arriving in Outlook, the message originating from the MOJITO server lacks the "Reply-To" in the header.
Are there other configuration issues that would thwart what the actual code is trying to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是我为解决此问题所做的更改:
我从 Scott Mitchell 的这篇精彩文章中发现了这种替代编码方法:
"在 ASP.NET 2.0 中发送电子邮件:回复、优先级和已读回执"
似乎两种方法都应该有效,但现在是时候了继续前行。
Here is what I changed to fix this:
I discovered this alternative coding approach from this great article by Scott Mitchell:
"Sending Email in ASP.NET 2.0: Reply-To, Priority, and Read Receipts"
Seems like either method should work but it is time to move on.