SmtpClient.CurrentSmtpServer Property

Gets the latest smtp server that is used to send e-mail message.

[Visual Basic]
Public Property CurrentSmtpServer As SmtpServer
public SmtpServer CurrentSmtpServer {get;}
public: __property SmtpServer^ get_CurrentSmtpServer();
public function get CurrentSmtpServer() : SmtpServer;

Property Value

The latest SmtpServer class instance that sends e-mail message.


This property is meaningless for sending email with specified smtp server, because the smtp server address is known. However, if the client sends e-mail without specified smtp server, the property indicates the latest smtp server that sent the email message.


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

[VB - Send Email]

Imports EASendMail

Sub SendMail()
    Dim oSmtp As SmtpClient = New SmtpClient
        Dim oMail As SmtpMail = New SmtpMail("TryIt")
        oMail.From = New MailAddress("")
        oMail.To.Add(New MailAddress(""))

        oMail.Subject = "test subject"
        oMail.TextBody = "test body"
        oSmtp.SendMail(Nothing, oMail)
        Console.WriteLine("The message was sent to {0} successfully", 

    Catch exp As System.Exception
        Console.WriteLine("Exception: {0}", exp.Message)
    End Try

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

[C# - Send Email] using System; using EASendMail; void SendMail() { SmtpClient oSmtp = new SmtpClient(); try { SmtpMail oMail = new SmtpMail("TryIt"); oMail.From = new MailAddress("" ); oMail.To.Add( new MailAddress("" )); oMail.Subject = "test subject"; oMail.TextBody = "test body"; oSmtp.SendMail(null, oMail); Console.WriteLine("The message was sent to {0} successfully", oSmtp.CurrentSmtpServer.Server); } catch( System.Exception exp ) { Console.WriteLine( "Exception: {0}", exp.Message ); } Console.WriteLine("SMTP LOG:\r\n"); Console.WriteLine(oSmtp.SmtpConversation); }
[C++/CLI - Send Email] using namespace System; using namespace EASendMail; void SendMail() { SmtpClient ^oSmtp = gcnew SmtpClient(); try { SmtpMail ^oMail = gcnew SmtpMail("TryIt"); oMail->From = gcnew MailAddress(""); oMail->To->Add( gcnew MailAddress("")); oMail->Subject = "test subject"; oMail->TextBody = "test body"; oSmtp->SendMail(NULL, oMail); Console::WriteLine("The message was sent to {0} successfully", oSmtp->CurrentSmtpServer->Server); } catch(Exception ^exp) { Console::WriteLine("Exception: Common: {0}", exp->Message); } Console::WriteLine("SMTP LOG:\r\n"); Console::WriteLine(oSmtp->SmtpConversation); }

See Also

Send E-mail Directly (Simulating SMTP server)