Delete-individual-POP3-messages - 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] **

Delete individual POP3 messages
VB code
Dim wodPop3 As wodPop3Com
Set wodPop3 = New wodPop3Com

'First we 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"
wodPop3.Blocking = True 'Use synchronous connections
'Then we connect to POP3 server.
wodPop3.Connect
'Upon successful connection GetAllHeaders will read all headers from the server.
'Using GetAllHeaders no files are created on local disk. All headers are kept in memory.
wodPop3.Messages.GetAllHeaders
Dim i As Integer
'Using Pop3Msgs Collection we will go though all messages.
For i = 0 To wodPop3.Messages.Count - 1
    'In this example we will check email subject if word SPAM is found.
    If InStr(1, wodPop3.Messages(i).Subject, "SPAM") Then
        'If such message is found we will mark message to be deleted by setting MarkDelete to True.
        wodPop3.Messages(i).MarkDelete = True
        Debug.Print "Message deleted: " & wodPop3.Messages(i).Subject
    End If
Next i
'Using Disconnect Method wodPop3 will first delete messages that is marked and finally disconnect.
wodPop3.Disconnect
VB.NET code
Dim wodPop3 As New WODPOP3COMLib.wodPop3Com

'First we 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"
wodPop3.Blocking = True 'Use synchronous connections
'Then we connect to POP3 server.
wodPop3.Connect()
'Upon successful connection GetAllHeaders will read all headers from the server.
'Using GetAllHeaders no files are created on local disk. All headers are kept in memory.
wodPop3.Messages.GetAllHeaders()
Dim i As Integer
'Using Pop3Msgs Collection we will go though all messages.
For i = 0 To wodPop3.Messages.Count - 1
    'In this example we will check email subject if word SPAM is found.
    If wodPop3.Messages(i).Subject.IndexOf("SPAM") >= 0 Then
        'If such message is found we will mark message to be deleted by setting MarkDelete to True.
        wodPop3.Messages(i).MarkDelete = True
        Console.WriteLine("Message deleted: " & wodPop3.Messages(i).Subject)
    End If
Next i
'Using Disconnect Method wodPop3 will first delete messages that is marked and finally disconnect.
wodPop3.Disconnect()
C# code
WODPOP3COMLib.wodPop3Com wodPop3 = new WODPOP3COMLib.wodPop3Com();

//First we 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";
wodPop3.Blocking = true; //Use synchronous connections
//Then we connect to POP3 server.
wodPop3.Connect();
//Upon successful connection GetAllHeaders will read all headers from the server.
//Using GetAllHeaders no files are created on local disk. All headers are kept in memory.
wodPop3.Messages.GetAllHeaders();
short i;
//Using Pop3Msgs Collection we will go though all messages.
for (i = 0; i <= wodPop3.Messages.Count - 1; i++)
{	
    //In this example we will check email subject if word SPAM is found.
    if (wodPop3.Messages[i].Subject.IndexOf("SPAM") >= 0)
    {
        //If such message is found we will mark message to be deleted by setting MarkDelete to True.
        wodPop3.Messages[i].MarkDelete = true;
        Console.WriteLine("Message deleted: " + wodPop3.Messages[i].Subject.ToString());
    }
}
//Using Disconnect Method wodPop3 will first delete messages that is marked and finally disconnect.
wodPop3.Disconnect();