SmtpMail.ReturnPath Property


Gets or sets a MailAddress of the delivery notification report address.

[Visual Basic]
Public Property ReturnPath As MailAddress
[C#]
public MailAddress ReturnPath {get; set;}
[C++]
public: __property MailAddress^ get_ReturnPath();
public: __property void set_ReturnPath(MailAddress^);
[JScript]
public function get ReturnPath() : MailAddress;
public function set ReturnPath(MailAddress);

Property Value

A MailAddress instance of the delivery report address.

Remarks

From

This property indicates the original email sender. This is what you see as the "FROM" in most mail clients.

Reply-To

This property indicates the reply address. Basically, when the user clicks "reply" in mail client, the Reply-To value should be used as the recpient address of the replied email. If you don't set this property, the Reply address is same as From address.

Sender

This property indicates the who submit/send the email. When the user received the email, the email client displays:
From: "sender address" on behalf of "from address".
If you don't set this property, the Sender address is same as From address. Sender property is common used by mail listing provider. This property also takes effect to DKIM/DomainKeys signature, if Sender is different with From address, then you should sign DKIM/DomainKeys based on Sender domain instead of From address domain.

Return-Path

This property indicates the delivery notification report address. If you don't set this property, the Return-Path address is same as From address. This property also takes effect to SPF record, if Return-Path is different with From address, then remote SMTP server checkes SPF record of Return-Path instead of From address.

Example

[Visual Basic, C#] To get the full samples of EASendMail, please refer to Samples section.

[VB - Send Email - From, Reply-To, Return-Path, Sender]
Imports EASendMail
Sub SendMail()
    Dim oMail As SmtpMail = New SmtpMail("TryIt")
    Dim oSmtp As SmtpClient = New SmtpClient

    Try
        Dim oServer As SmtpServer = New SmtpServer("myserveraddress")
        
        ' Set ReturnPath 
        ' then the failure-report will be sent to this address instead of From
        oMail.ReturnPath = "report@adminsystem.com"
        
        ' Set ReplyTo, the email will be replied to this address instead of From
        oMail.ReplyTo = "reply@adminsystem.com"
 
        ' Set Sender, 
        ' If the user received the email, the email client will display:
        ' "sender@emailarchitect.net" on behalf of "from@adminsystem.com".
        oMail.Sender = "sender@emailarchitect.net"

        ' oMail.From = New MailAddress( "From Tester", "from@adminsystem.com" )
        ' oMail.From = New MailAddress( "From Tester <from@adminsystem.com>" )

        oMail.From = New MailAddress("from@adminsystem.com")
        oMail.To.Add(New MailAddress("to@adminsystem.com"))
        
        oMail.Subject = "test subject"
        oMail.TextBody = "test body"
               
        oSmtp.SendMail( oServer, oMail )
        Console.WriteLine( "message was sent" )
        
    Catch exp As SmtpTerminatedException
        Console.WriteLine(exp.Message)
    Catch exp As SmtpServerException
        Console.WriteLine("Exception: Server Respond: {0}", exp.ErrorMessage)
    Catch exp As System.Net.Sockets.SocketException
        Console.WriteLine("Exception: Networking Error: {0} {1}", exp.ErrorCode, exp.Message)
    Catch exp As System.ComponentModel.Win32Exception
        Console.WriteLine("Exception: System Error: {0} {1}", exp.ErrorCode, exp.Message)
    Catch exp As System.Exception
        Console.WriteLine("Exception: Common: {0}", exp.Message)
    End Try

    Console.WriteLine("SMTP LOG:" & vbCrLf)
    Console.WriteLine(oSmtp.SmtpConversation)
End Sub

[C# - Send Email - From, Reply-To, Return-Path, Sender]
using System;
using EASendMail;
void SendMail()
{
    SmtpMail oMail = new SmtpMail("TryIt");
    SmtpClient oSmtp = new SmtpClient();

    try
    {
        SmtpServer oServer = new SmtpServer("myserveraddress");
        
        // Set ReturnPath 
        // then the failure-report will be sent to this address instead of From
        oMail.ReturnPath = "report@adminsystem.com";
        
        // Set ReplyTo, the email will be replied to this address instead of From
        oMail.ReplyTo = "reply@adminsystem.com";
 
        // Set Sender, 
        // If the user received the email, the email client will display:
        // "sender@emailarchitect.net" on behalf of "from@adminsystem.com".
        oMail.Sender = "sender@emailarchitect.net";

        ' oMail.From = New MailAddress( "From Tester", "from@adminsystem.com" )
        // oMail.From = New MailAddress( "From Tester <from@adminsystem.com>" )

        oMail.From = new MailAddress("from@adminsystem.com" );
        oMail.To.Add( new MailAddress("to@adminsystem.com" ));
        oMail.Subject = "test subject";
        oMail.TextBody = "test body";
        
        oSmtp.SendMail( oServer, oMail );
        Console.WriteLine( "message was sent" );
    }
    catch( SmtpTerminatedException exp )
    {
        Console.WriteLine( exp.Message );
    }
    catch( SmtpServerException exp )
    {
        Console.WriteLine( "Exception: Server Respond: {0}", exp.ErrorMessage );
    }
    catch( System.Net.Sockets.SocketException exp )
    {
        Console.WriteLine( "Exception: Networking Error: {0} {1}", exp.ErrorCode, exp.Message );
    }
    catch( System.ComponentModel.Win32Exception exp )
    {
        Console.WriteLine( "Exception: System Error: {0} {1}", exp.ErrorCode, exp.Message );            
    }
    catch( System.Exception exp )
    {
        Console.WriteLine( "Exception: Common: {0}", exp.Message );         
    }

    Console.WriteLine( "SMTP LOG:\r\n" );
    Console.WriteLine( oSmtp.SmtpConversation );
}

See Also

From, ReplyTo, Sender and Return-Path
SmtpMail.ReplyTo Property
SmtpMail.Sender Property
SmtpMail.From Property