Question

J'ai un projet d'application Web développé et testé unité sur une machine Windows XP (IIS 5.1). Il a été publié à un Win2003Server (IIS 6.0). Une caractéristique de l'application envoie un email avec un en-tête « Reply-To » (extrait ci-dessous). Sur IIS 5.1 la machine, la Reply-To apparaît correctement dans l'en-tête. Lorsqu'il est envoyé de l'IIS 6.0 PC, l'en-tête ne contient pas l'adresse de réponse (voir ci-dessous):

    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

Les suivants En-têtes Internet sont collés de MS Outlook 2003 - Vue - Options:

réponse valide comme envoyé de la machine JOHNXP (le dev PC avec IIS 5.1):

Return-path: <Service@zipeee.com>
Received: from JohnXP (unverified [10.10.30.66]) by mail.cbmiweb.com
(Rockliffe SMTPRA 9.2.0) with ESMTP id <B0003406093@mail.cbmiweb.com>;
Mon, 28 Jun 2010 15:16:25 -0400
Message-ID: <B0003406093@mail.cbmiweb.com>
Reply-To: terriadams@cox.net
MIME-Version: 1.0
From: Service@ZIPeee.com
To: johna@cbmiweb.com
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

manquant Répondre à tel qu'envoyé de la machine MOJITO (le serveur 2003 avec IIS 6.0):

Return-path: <Service@zipeee.com>
Received: from MOJITO (unverified [10.10.30.14]) by mail.cbmiweb.com
(Rockliffe SMTPRA 9.2.0) with ESMTP id <B0003405883@mail.cbmiweb.com>;
Mon, 28 Jun 2010 13:37:53 -0400
Message-ID: <B0003405883@mail.cbmiweb.com>
MIME-Version: 1.0
From: Service@ZIPeee.com
To: johna@cbmiweb.com
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

J'ai même mis en place VStudio2008 sur la machine Win2003 et arrêtée à un point d'arrêt dans le code ci-dessus pour vous assurer que le MailMessage était en fait être construit correctement avec le « Reply-To » ajouté à l'en-tête (il est). Pourtant, en arrivant dans Outlook, l'origine de message du serveur MOJITO n'a pas la « Reply-To » dans l'en-tête.

Y at-il d'autres problèmes de configuration qui contrecarrerait ce que le code actuel essaie de faire?

Était-ce utile?

La solution

Voici ce que j'ai changé pour résoudre ce problème:

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 

Je découvre cette approche de codage alternatif de ce grand article de Scott Mitchell:

"Envoi d'un courriel dans ASP.NET 2.0: Répondre à, la priorité et Accusés de lecture «

On dirait une ou l'autre méthode devrait fonctionner, mais il est temps de passer à autre chose.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top