SmtpMail.RelyTo Property


Gets or sets a MailAddress of the reply address.

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

Property Value

A MailAddress instance of the reply 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.

Examples

[Visual Basic, C#, JavaScript] The following example demonstrates how to send email in Windows 8 Store App. To get the full samples of EASendMail, please refer to Samples section.

[C# - Send Email - From, Reply-To, Return-Path, Sender - XAML]
using EASendMail;
using System.Threading.Tasks;

private async Task SendEmail()
{
    String Result = "";
    try
    {
        SmtpMail oMail = new SmtpMail("TryIt");
        SmtpClient oSmtp = new SmtpClient();

        // Set ReturnPath 
        // then the failure-report will be sent to this address instead of From
        oMail.ReturnPath = new MailAddress( "report@adminsystem.com" );
        
        // Set ReplyTo, the email will be replied to this address instead of From
        oMail.ReplyTo = new MailAddress( "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 = new MailAddress( "sender@emailarchitect.net" );

        // Set from email address, please change it to yours 
        oMail.From = new MailAddress("from@adminsystem.com");

        // Add recipient email address, please change it to yours
        oMail.To.Add(new MailAddress("support@emailarchitect.net"));

        // Set email subject
        oMail.Subject = "test email from C# XAML project";

        // Set email body
        oMail.TextBody = "this is a test email sent from Windows Store App, do not reply";

        // Your SMTP server address
        SmtpServer oServer = new SmtpServer("smtp.emailarchitect.net");

        // User and password for ESMTP authentication            
        oServer.User = "test@emailarchitect.net";
        oServer.Password = "testpassword";

        // If your SMTP server requires TLS connection on 25 port, please add this line
        // oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

        // If your SMTP server requires SSL connection on 465 port, please add this line
        // oServer.Port = 465;
        // oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

        await oSmtp.SendMailAsync(oServer, oMail);
        Result = "Email was sent successfully!";
    }
    catch (Exception ep)
    {
        Result = String.Format("Failed to send email with the following error: {0}", ep.Message);
    }

    // Display Result by Diaglog box
    Windows.UI.Popups.MessageDialog dlg = new
        Windows.UI.Popups.MessageDialog(Result);
           
    await dlg.ShowAsync();
}

[VB - Send Email - From, Reply-To, Return-Path, Sender - XAML]
Imports EASendMail

Private Async Function SendEmail() As Task
    Dim Result As String = ""
    Try

        Dim oMail As New SmtpMail("TryIt")
        Dim oSmtp As New SmtpClient()

        ' Set ReturnPath 
        ' then the failure-report will be sent to this address instead of From
        oMail.ReturnPath = New MailAddress( "report@adminsystem.com" )
        
        ' Set ReplyTo, the email will be replied to this address instead of From
        oMail.ReplyTo = New MailAddress( "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 = New MailAddress( "sender@emailarchitect.net" )

        ' Set from email address, please change it to yours
        oMail.From = New MailAddress("from@adminsystem.com")

        ' Add recipient email address, please change it to yours
        oMail.To.Add(New MailAddress("support@emailarchitect.net"))

        ' Set email subject
        oMail.Subject = "test email from VB XAML project"

        ' Set email body
        oMail.TextBody = "this is a test email sent from Windows Store App, do not reply"

        ' Your SMTP server address
        Dim oServer As New SmtpServer("smtp.emailarchitect.net")

        ' User and password for ESMTP authentication            
        oServer.User = "test@emailarchitect.net"
        oServer.Password = "testpassword"

        ' If your SMTP server requires TLS connection on 25 port, please add this line
        ' oServer.ConnectType = SmtpConnectType.ConnectSSLAuto

        ' If your SMTP server requires SSL connection on 465 port, please add this line
        ' oServer.Port = 465
        ' oServer.ConnectType = SmtpConnectType.ConnectSSLAuto

        Await oSmtp.SendMailAsync(oServer, oMail)
        Result = "Email was sent successfully!"

    Catch ep As Exception
        Result = String.Format("Failed to send email with the following error: {0}", ep.Message)
    End Try

    ' Display Result by Diaglog box
    Dim dlg As New Windows.UI.Popups.MessageDialog(Result)
    Await dlg.ShowAsync()
End Function

[JavaScript - Send Email - From, Reply-To, Return-Path, Sender - HTML5]
function sendMail() {
    var result = "";

    var oMail = new EASendMail.SmtpMail("TryIt");
    var oSmtp = new EASendMail.SmtpClient();

    // Set ReturnPath 
    // then the failure-report will be sent to this address instead of From
    oMail.returnPath = new EASendMail.MailAddress( "report@adminsystem.com" );
        
    // Set ReplyTo, the email will be replied to this address instead of From
    oMail.replyTo = new EASendMail.MailAddress( "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 = new EASendMail.MailAddress( "sender@emailarchitect.net" );

    // Set from email address, please change it to yours 
    oMail.from = new EASendMail.MailAddress("from@adminsystem.com");

    // Add recipient email address, please change it to yours
    oMail.to.add(new EASendMail.MailAddress("support@emailarchitect.net"));

    // Set email subject
    oMail.subject = "test email from JavaScript HTML5 project";

    // Set email body
    oMail.textBody = "this is a test email sent from Windows Store App, do not reply";

    // Your SMTP server address
    var oServer = new EASendMail.SmtpServer("smtp.emailarchitect.net");

    // User and password for ESMTP authentication            
    oServer.user = "test@emailarchitect.net";
    oServer.password = "testpassword";

    // If your SMTP server requires TLS connection on 25 port, please add this line
    // oServer.connectType = EASendMail.SmtpConnectType.connectSSLAuto;

    // If your SMTP server requires SSL connection on 465 port, please add this line
    // oServer.port = 465;
    // oServer.connectType = EASendMail.SmtpConnectType.connectSSLAuto;

    oSmtp.sendMailAsync(oServer, oMail).then(function (e) {
        result = "Email was sent successfully!";

        // Display Result by Diaglog box
        (new Windows.UI.Popups.MessageDialog(result, "Success")).showAsync();
    },

    function (e) {
        // because javascript exception only gives the stack trace messages, but it is not
        // real description of exception, so we give a property lastErrorMessage for javascript.
        if (oSmtp.lastErrorMessage != "") {
            result = oSmtp.lastErrorMessage;
        }
        else {
            result = e.message;
        }
        oSmtp.close();

        // Display Result by Diaglog box
        (new Windows.UI.Popups.MessageDialog(result, "Error Information")).showAsync();
    });
}

See Also

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