Using-POP3-Events-in-wodPop3 - 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] **

Using POP3 Events in wodPop3
VB code
'Declare wodPOP3 ActiveX component with wodPOP3 Events
Dim WithEvents wodPop3 As wodPop3Com
Private Sub Form_Load()
    Set wodPop3 = New wodPop3Com
   
    'Set up the hostname, login and password for POP3 server.
    wodPop3.HostName = "your_pop3_hostname"
    wodPop3.Login = "your_pop3_login"
    wodPop3.Password = "your_pop3_password"
    'Connect to POP3 server.
    wodPop3.Connect
End Sub

'Connected Event fires when wodPOP3 component connects to the server.
Private Sub wodPop3_Connected()
    Debug.Print "Connected Event"
    'Using GetAll we will download all messages.
    wodPop3.Messages.GetAll
End Sub

'Progress Event fires during message retrieval process.
Private Sub wodPop3_Progress(ByVal Position As Long, ByVal Total As Long)
    Debug.Print "Progress: " & Position & "/" & Total
End Sub

'Received Event fires when wodPOP3 component finishes receiving the message.
Private Sub wodPop3_Received(ByVal Message As WODPOP3COMLib.IPop3Msg, ByVal HeadersOnly As Boolean)
    'We will display here message From and Subject details.
    Debug.Print "From:   " & Message.From
    Debug.Print "Subject: " & Message.Subject
End Sub

'Done Event fires when wodPOP3 component finishes execution of some method.
'In this example we use GetAll Method.
Private Sub wodPop3_Done(ByVal ErrorCode As Long, ByVal ErrorText As String, ByVal HeadersOnly As Boolean)
    If ErrorCode = 0 Then
        Debug.Print "Done with receiving messages"
        'Download of messages is done so we can disconnect now.
        wodPop3.Disconnect
    Else
        'If some error occur during execution of wodPOP3 method error will be received here.
        MsgBox "Done Event Error: " & ErrorText
    End If
End Sub

'Disconnected Event fires when wodPOP3 component disconnects from the server.
Private Sub wodPop3_Disconnected(ByVal ErrorCode As Long, ByVal ErrorText As String)
    If ErrorCode = 0 Then
        Debug.Print "Disconnected from server"
    Else
        'If there were some error during connection with server or server closes connection
        'we will receive that error here.
        MsgBox "Disconnected Event Error: " & ErrorText
    End If
End Sub

'StateChange Event fires when wodPOP3 component changes its state.
Private Sub wodPop3_StateChange(ByVal OldState As WODPOP3COMLib.StatesEnum)
    'Display component current state.
    Debug.Print "State: " & wodPop3.StateText
End Sub
VB.NET code
'Declare wodPOP3 ActiveX component with wodPOP3 Events.
Dim WithEvents wodPop3 As WODPOP3COMLib.wodPop3Com
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    wodPop3 = New WODPOP3COMLib.wodPop3Com

    'Set up the hostname, login and password for POP3 server.
    wodPop3.Hostname = "your_pop3_hostname"
    wodPop3.Login = "your_pop3_login"
    wodPop3.Password = "your_pop3_password"
    'Connect to POP3 server.
    wodPop3.Connect()
End Sub

'Connected Event fires when wodPOP3 component connects to the server.
Private Sub wodPop3_Connected() Handles wodPop3.Connected
    Console.WriteLine("Connected Event")
    'Using GetAll we will download all messages.
    wodPop3.Messages.GetAll()
End Sub

'Progress Event fires during message retrieval process.
Private Sub wodPop3_Progress(ByVal Position As Integer, ByVal Total As Integer) Handles wodPop3.Progress
    Console.WriteLine("Progress: " & Position & "/" & Total)
End Sub

'Received Event fires when wodPOP3 component finishes receiving the message.
Private Sub wodPop3_Received(ByVal Message As WODPOP3COMLib.Pop3Msg, ByVal HeadersOnly As Boolean) Handles wodPop3.Received
    'We will display here message From and Subject details.
    Console.WriteLine("From:   " & Message.From)
    Console.WriteLine("Subect: " & Message.Subject)
End Sub

'Done Event fires when wodPOP3 component finishes execution of some method.
'In this example we use GetAll Method.
Private Sub wodPop3_Done(ByVal ErrorCode As Integer, ByVal ErrorText As String, ByVal HeadersOnly As Boolean) Handles wodPop3.Done
    If ErrorCode = 0 Then
        Console.WriteLine("Done with receiving messages")
        'Download of messages is done so we can disconnect now.
        wodPop3.Disconnect()
    Else
        'If some error occur during execution of wodPOP3 method error will be received here.
        MsgBox("Done Event Error: " & ErrorText)
    End If
End Sub

'Disconnected Event fires when wodPOP3 component disconnects from the server.
Private Sub wodPop3_Disconnected(ByVal ErrorCode As Integer, ByVal ErrorText As String) Handles wodPop3.Disconnected
    If ErrorCode = 0 Then
        Console.WriteLine("Disconnected from server")
    Else
        'If there were some error during connection with server or server closes connection
        'we will receive that error here.
        MsgBox("Disconnected Event Error: " & ErrorText)
    End If
End Sub

'StateChange Event fires when wodPOP3 component changes its state.
Private Sub wodPop3_StateChange(ByVal OldState As WODPOP3COMLib.StatesEnum) Handles wodPop3.StateChange
    'Display component current state.
    Console.WriteLine("State: " & wodPop3.StateText)
End Sub
C# code
//Declare wodPop3 ActiveX component.
WODPOP3COMLib.wodPop3Com wodPop3;
private void Form1_Load(object sender, EventArgs e)
{
    wodPop3 = new WODPOP3COMLib.wodPop3Com();

    //Declare wodPop3 Events.
    wodPop3.Connected += new WODPOP3COMLib._IwodPop3ComEvents_ConnectedEventHandler(wodPop3_Connected);
    wodPop3.Disconnected += new WODPOP3COMLib._IwodPop3ComEvents_DisconnectedEventHandler(wodPop3_Disconnected);
    wodPop3.Done += new WODPOP3COMLib._IwodPop3ComEvents_DoneEventHandler(wodPop3_Done);
    wodPop3.Progress += new WODPOP3COMLib._IwodPop3ComEvents_ProgressEventHandler(wodPop3_Progress);
    wodPop3.Received += new WODPOP3COMLib._IwodPop3ComEvents_ReceivedEventHandler(wodPop3_Received);
    wodPop3.StateChange += new WODPOP3COMLib._IwodPop3ComEvents_StateChangeEventHandler(wodPop3_StateChange);

    //Set up the hostname, login and password for POP3 server.
    wodPop3.Hostname = "your_pop3_hostname";
    wodPop3.Login = "your_pop3_login";
    wodPop3.Password = "your_pop3_password";
    //Connect to POP3 server.
    wodPop3.Connect();
}

//Connected Event fires when wodPOP3 component connects to the server.
void wodPop3_Connected()
{
    Console.WriteLine("Connected Event");
    //Using GetAll we will download all messages.
    wodPop3.Messages.GetAll();
}

//Progress Event fires during message retrieval process.
void wodPop3_Progress(int Position, int Total)
{
    Console.WriteLine("Progress: " + Position + "/" + Total);
}

//Received Event fires when wodPOP3 component finishes receiving the message.
void wodPop3_Received(WODPOP3COMLib.Pop3Msg Message, bool HeadersOnly)
{
    //We will display here message From and Subject details.
    Console.WriteLine("From:   " + Message.From);
    Console.WriteLine("Subject: " + Message.Subject);
}

//Done Event fires when wodPOP3 component finishes execution of some method.
//In this example we use GetAll Method.
void wodPop3_Done(int ErrorCode, string ErrorText, bool HeadersOnly)
{
    if (ErrorCode == 0)
    {
        Console.WriteLine("Done with receiving messages");
        //Download of messages is done so we can disconnect now.
        wodPop3.Disconnect();
    }
    else
    {
        //If some error occur during execution of wodPOP3 method error will be received here.
        MessageBox.Show("Done Event Error: " + ErrorText);
    }
}

//Disconnected Event fires when wodPOP3 component disconnects from the server.
void wodPop3_Disconnected(int ErrorCode, string ErrorText)
{
    if (ErrorCode == 0)
    {
        Console.WriteLine("Disconnected from server");
    }
    else
    {
        //If there were some error during connection with server or server closes connection
        //we will receive that error here.
        MessageBox.Show("Disconnected Event Error: " + ErrorText);
    }
}

//StateChange Event fires when wodPOP3 component changes its state.
void wodPop3_StateChange(WODPOP3COMLib.StatesEnum OldState)
{
    //Display component current state.
    Console.WriteLine("State: " + wodPop3.get_StateText(wodPop3.State));
}