SmtpMail.Subject Property


Gets or sets the subject of the e-mail message.

[Visual Basic]
Public Property Subject As String
[C#]
public string Subject {get; set;}
[C++]
public: __property String^ get_Subject();
public: __property void set_Subject(String^);
[JScript]
public function get Subject() : String;
public function set Subject(String);

Property Value

A String value indicating the subject of the e-mail message.

Example

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

[VB - Send email with subject]

Imports EASendMail

Sub SendMail()

    Try
        Dim oServer As SmtpServer = New SmtpServer("myserveraddress")
        ' SMTP user authentication
        oServer.User = "myusername"
        oServer.Password = "mypassword"

        ' Most mordern SMTP servers require SSL/TLS connection now.
        ' ConnectTryTLS means if server supports SSL/TLS, SSL/TLS will be used automatically.
        oServer.ConnectType = SmtpConnectType.ConnectTryTLS

        Dim oMail As SmtpMail = New SmtpMail("TryIt")
        oMail.From = New MailAddress("from@adminsystem.com")
        oMail.To.Add(New MailAddress("to@adminsystem.com"))

        oMail.Subject = "test subject"
        oMail.TextBody = "test body"

        Dim oSmtp As SmtpClient = New SmtpClient()
        oSmtp.SendMail(oServer, oMail)
        Console.WriteLine("message was sent")
    Catch exp As Exception
        Console.WriteLine("Exception: {0}", exp.Message)
    End Try

End Sub


[C# - Send email with subject] using System; using EASendMail; void SendMail() { try { SmtpServer oServer = new SmtpServer("myserveraddress"); // SMTP user authentication oServer.User = "myusername"; oServer.Password = "mypassword"; // Most mordern SMTP servers require SSL/TLS connection now. // ConnectTryTLS means if server supports SSL/TLS, SSL/TLS will be used automatically. oServer.ConnectType = SmtpConnectType.ConnectTryTLS; SmtpMail oMail = new SmtpMail("TryIt"); oMail.From = new MailAddress("from@adminsystem.com"); oMail.To.Add(new MailAddress("to@adminsystem.com")); oMail.Subject = "test subject"; oMail.TextBody = "test body"; SmtpClient oSmtp = new SmtpClient(); oSmtp.SendMail(oServer, oMail); Console.WriteLine("message was sent"); } catch (Exception exp) { Console.WriteLine("Exception: {0}", exp.Message); } }
[C++/CLI - Send email with subject] using namespace System; using namespace EASendMail; void SendMail() { try { SmtpServer ^oServer = gcnew SmtpServer("myserveraddres"); // SMTP user authentication oServer->User = "myusername"; oServer->Password = "mypassword"; // Most mordern SMTP servers require SSL/TLS connection now. // ConnectTryTLS means if server supports SSL/TLS, SSL/TLS will be used automatically. oServer->ConnectType = SmtpConnectType::ConnectTryTLS; SmtpMail ^oMail = gcnew SmtpMail("TryIt"); oMail->From = gcnew MailAddress("from@adminsystem.com"); oMail->To->Add(gcnew MailAddress("to@adminsystem.com")); oMail->Subject = "test subject"; oMail->TextBody = "test body"; SmtpClient ^oSmtp = gcnew SmtpClient(); oSmtp->SendMail(oServer, oMail); Console::WriteLine("message was sent"); } catch (Exception ^exp) { Console::WriteLine("Exception: {0}", exp->Message); } }

See Also

SmtpMail.TextBody Property
SmtpMail.HtmlBody Property