views:

17

answers:

1

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?

A: 

Here is what I changed to fix this:

Dim MyMsg As New MailMessage
With MyMsg
        .From = New MailAddress(emailfrom)
        .ReplyTo = New MailAddress(sReplyTo)    'new code that fixed the problem
        '.Headers.Add("Reply-To", sReplyTo)     'old code that works on WinXP IIS 5.1 

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.

John Galt