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

The value specified by this property is used with SMTP "MAIL FROM" command during SMTP conversation, and the delivery notification report will be sent to this address. If this property is not specified, the value of From property will be used in "MAIL FROM" command.

Example

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

[Visual Basic]
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")
        
        ' the failure-report will be sent to this address instead of From
        ' oMail.ReturnPath = "report@adminsystem.com"
        
        ' oMail.From = New MailAddress( "Tester", "test@adminsystem.com" )
        ' oMail.From = New MailAddress( "Tester<test@adminsystem.com>" )
        ' oMail.From = New MailAddress( "test@adminsystem.com" )
        
        'inserts a reply-to header, then the email will be replied to this address instead of From
        'oMail.Headers.Insert( 0, new HeaderItem( "Reply-To", "reply@adminsystem.com" ))
 

        oMail.From = New MailAddress("from@adminsystem.com")
        oMail.ReplyTo = New MailAddress("reply@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#]
using System;
using EASendMail;
void SendMail()
{
    SmtpMail oMail = new SmtpMail("TryIt");
    SmtpClient oSmtp = new SmtpClient();

    try
    {
        SmtpServer oServer = new SmtpServer("myserveraddress");
        
        // the failure-report will be sent to this address instead of From
        // oMail.ReturnPath = "report@adminsystem.com";
        
        // oMail.From = New MailAddress( "Tester", "test@adminsystem.com" )
        // oMail.From = New MailAddress( "Tester<test@adminsystem.com>" )
        // oMail.From = New MailAddress( "test@adminsystem.com" )
        //inserts a reply-to header, then the email will be replied to this address instead of From
        //oMail.Headers.Insert( 0, new HeaderItem( "Reply-To", "reply@adminsystem.com" ));
    
        oMail.From = new MailAddress("from@adminsystem.com" );
        oMail.ReplyTo = new MailAddress("reply@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 );
}