Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
Download Email Headers and Delete Selected Email
Downloads email headers from a POP3 server and deletes emails with subjects containing certain substrings.
' Delete mail where the subject contains certain substrings
Private Sub Command1_Click()
Dim mailman As New ChilkatMailMan2
' Anything begins the 30-day trial
mailman.UnlockComponent "unlockCode"
' Set the POP3 hostname and loging username/password
mailman.MailHost = "mail.chilkatsoft.com"
mailman.PopUsername = "myLogin"
mailman.PopPassword = "myPassword"
' Copy all mail headers.
Dim bundle As ChilkatEmailBundle2
Set bundle = mailman.GetAllHeaders(1)
If (bundle Is Nothing) Then
MsgBox mailman.LastErrorText
Exit Sub
End If
Dim email As ChilkatEmail2
For i = 0 To bundle.MessageCount - 1
Set email = bundle.GetEmail(i)
Debug.Print email.Subject
List1.AddItem email.Subject
' This if for the sake of example. It would make a very very
' poor SPAM filter...
If (InStr(email.Subject, "Viagra")) Then
' Remove this email from the POP3 server.
mailman.DeleteEmail email
ElseIf (InStr(email.Subject, "Prescription Meds")) Then
' Remove this email from the POP3 server.
mailman.DeleteEmail email
ElseIf (InStr(email.Subject, "Human Growth Hormone")) Then
' Remove this email from the POP3 server.
mailman.DeleteEmail email
End If
Next
End Sub
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.