Send-Email-Asynchronously - WeOnlyDo Software example code



All

wodCrypt (12)
wodSSH (10)
wodSFTP (23)
wodSSHServer (1)
wodSSHTunnel (11)
wodSSHpackage
wodSFTPdll

wodSSH.NET (10)
wodSFTP.NET (24)
wodFtpDLX.NET (22)
wodWebServer.NET (10)

wodAppUpdate (13)
wodHttpDLX (8)
wodFtpDLX (22)
wodTelnetDLX
wodFTPServer (3)
wodWebServer (10)
wodVPN
wodXMPP (13)
All ** [Visual Basic] ** [C#] ** [VB.NET] **

Send HTML e-mail from .html file using Smarthost
VB code
Dim WithEvents wodSMTP As wodSmtpCom
Private Sub Form_Load()

    Set wodSMTP = New wodSmtpCom

    With wodSMTP
        .HostName = "your_smtp_server"
        .Login = "your_login"
        .Password = "your_password"
        
        ' Use Username/Password Authentication
        .Authentication = AuthLogin
    End With

    ' Connect to your SMTP server
    wodSMTP.Connect
    
End Sub

' Once successfully connected to server, we will attempt to send out e-mail.
Private Sub wodSMTP_Connected(ByVal Capabilities As String)
    wodSMTP.SendSimple "sender@email.com", "recipient@email.com", "This is subject.", "This is what this e-mail is about."
End Sub

' Done event is triggered once Sending is done. If everything worked as expected,
' ErrorCode should be 0. We will disconnect here.
Private Sub wodSMTP_Done(ByVal ErrorCode As Long, ByVal ErrorText As String)
    wodSMTP.Disconnect
End Sub

' This event is used just for debugging purposes. It will display component States
' as it connects to server and sends the message.
Private Sub wodSMTP_StateChange(ByVal OldState As WODSMTPCOMLib.SmtpStates)
    Debug.Print "State changed to " & wodSMTP.StateText
End Sub
VB.Net code
Dim WithEvents wodSMTP As WODSMTPCOMLib.wodSmtpCom
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    wodSMTP = New WODSMTPCOMLib.wodSmtpCom

    With wodSMTP
        .Hostname = "your_smtp_server"
        .Login = "your_login"
        .Password = "your_password"

        ' Use Username/Password Authentication
        .Authentication = WODSMTPCOMLib.SmtpAuthentications.AuthLogin
    End With

    ' Connect to your SMTP server
    wodSMTP.Connect()

End Sub

' Once successfully connected to server, we will attempt to send out e-mail.
Private Sub wodSMTP_Connected(ByVal Capabilities As String)
    wodSMTP.SendSimple("sender@email.com", "recipient@email.com", "This is subject.", "This is what this e-mail is about.")
End Sub

' Done event is triggered once Sending is done. If everything worked as expected,
' ErrorCode should be 0. We will disconnect here.
Private Sub wodSMTP_Done(ByVal ErrorCode As Long, ByVal ErrorText As String)
    wodSMTP.Disconnect()
End Sub

' This event is used just for debugging purposes. It will display component States
' as it connects to server and sends the message.
Private Sub wodSMTP_StateChange(ByVal OldState As WODSMTPCOMLib.SmtpStates)
    Debug.Print("State changed to " & wodSMTP.StateText)
End Sub
C# code
private WODSMTPCOMLib.wodSmtpCom wodSMTP;
private void Form1_Load(object sender, EventArgs e)
{
    wodSMTP = new WODSMTPCOMLib.wodSmtpCom();

    wodSMTP.Connected += new WODSMTPCOMLib._IwodSmtpComEvents_ConnectedEventHandler(wodSMTP_Connected);
    wodSMTP.Done += new WODSMTPCOMLib._IwodSmtpComEvents_DoneEventHandler(wodSMTP_Done);
    wodSMTP.StateChange += new WODSMTPCOMLib._IwodSmtpComEvents_StateChangeEventHandler(wodSMTP_StateChange);

    wodSMTP.HostName = "your_smtp_server";
    wodSMTP.Login = "your_login";
    wodSMTP.Password = "your_password";
    
    // Use Username/Password Authentication
    wodSMTP.Authentication = WODSMTPCOMLib.SmtpAuthentications.AuthLogin;

    // Connect to your SMTP server
    wodSMTP.Connect();

}
    // This event is used just for debugging purposes. It will display component States
    // as it connects to server and sends the message.
    void wodSMTP_StateChange(WODSMTPCOMLib.SmtpStates OldState)
    {
        Console.WriteLine("State changed to " + wodSMTP.get_StateText(wodSMTP.State));
    }

    // Done event is triggered once Sending is done. If everything worked as expected,
    // ErrorCode should be 0. We will disconnect here.
    void wodSMTP_Done(int ErrorCode, string ErrorText)
    {
        wodSMTP.Disconnect();
    }

    // Once successfully connected to server, we will attempt to send out e-mail.
    void wodSMTP_Connected(string Capabilities)
    {
        wodSMTP.SendSimple("sender@email.com", "recipient@email.com", "This is subject.", "This is what this e-mail is about.");
    }