.netmailmessage

.NET MailMessage DeliveryNotificationOptions stop working when adding a CC


I recently added a CC to a .NET MailMessage. As soon as I did that the read return receipts stopped working. The read receipts are quite handy as they not only show who has read the message (provided the client supports it) but also the 'Deleted without being read' is useful feedback.

Using Msg As New MailMessage

            Msg.To.Add(New MailAddress(SendTo))
            Msg.From = New MailAddress(From)
            Msg.CC.Add(vCC)
            Msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess
            Msg.Subject = Subject
            Msg.Body = Body
            Msg.BodyEncoding = Encoding.GetEncoding("iso-8859-1")
            Dim AV As AlternateView = AlternateView.CreateAlternateViewFromString(Body, Nothing, "Text/html")
            AV.TransferEncoding = Mime.TransferEncoding.QuotedPrintable
            Msg.AlternateViews.Add(AV)
            Try
                Using vsmpt As New SmtpClient
                    vsmpt.Host = "OurMailServer.net"
                    vsmpt.Send(Msg)
                End Using
                Return True
            Catch ex As Exception
                EmailError(ex)
                Return False
            End Try
        End Using

Is there any reason for this strange behaviour?

Thanks

MailMessage


Solution

  • Figured it out - added

    Msg.Headers.Add("Return-Receipt-To", From)
    Msg.Headers.Add("Disposition-Notification-To", From)
    

    Something must have changed recently with

     Msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess
    

    As that used to provide a return receipt, but doesn't seem to do anything now.

    Anyway, now works :-)