Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Bounced Mail Handler
VB.NET sample source code showing how to create a bounced mail handler. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' The Chilkat Bounce component is used to classify an email as
' one of several types of automated replies such as bounced
' email messages, virus warnings, out-of-office replies, etc.
' To read email from a POP3 server, the Chilkat Mail component
' (licensed separately) is used.
Dim success As Boolean
Dim mailman As New Chilkat.MailMan()
mailman.UnlockComponent("MailUnlockCode")
mailman.MailHost = "mail.chilkatsoft.com"
mailman.PopUsername = "login"
mailman.PopPassword = "password"
Dim bounce As New Chilkat.Bounce()
success = bounce.UnlockComponent("BounceUnlockCode")
If (success <> true) Then
MsgBox(bounce.LastErrorText)
Exit Sub
End If
' Read email from the POP3 server.
Dim bundle As Chilkat.EmailBundle
bundle = mailman.CopyMail()
If (Not (bundle Is Nothing)) Then
' Loop over each email...
Dim email As Chilkat.Email
Dim i As Long
For i = 0 To bundle.MessageCount - 1
email = bundle.GetEmail(i)
' See if this is a bounced email.
' This sets the properties of the Bounce object
success = bounce.ExamineEmail(email)
If (success = False) Then
ListBox1.Items.Add("Failed to classify email")
ElseIf (bounce.BounceType = 0) Then
' Not a bounce, skip it.
ElseIf (bounce.BounceType = 1) Then
' Hard bounce, log the email address
ListBox1.Items.Add("Hard Bounce: " & bounce.BounceAddress)
ElseIf (bounce.BounceType = 2) Then
' Soft bounce, log the email address
ListBox1.Items.Add("Soft Bounce: " & bounce.BounceAddress)
ElseIf (bounce.BounceType = 3) Then
' General bounce, no email address available.
ListBox1.Items.Add("General Bounce: No email address")
ElseIf (bounce.BounceType = 4) Then
' General bounce, log the email address
ListBox1.Items.Add("General Bounce: " & bounce.BounceAddress)
ElseIf (bounce.BounceType = 5) Then
' Mail blocked, log the email address
ListBox1.Items.Add("Mail Blocked: " & bounce.BounceAddress)
ElseIf (bounce.BounceType = 6) Then
' Auto-reply, log the email address
ListBox1.Items.Add("Auto-Reply: " & bounce.BounceAddress)
ElseIf (bounce.BounceType = 7) Then
' Transient (recoverable) Failure, log the email address
ListBox1.Items.Add("Transient Failure: " & bounce.BounceAddress)
ElseIf (bounce.BounceType = 8) Then
' Subscribe request, log the email address
ListBox1.Items.Add("Subscribe Request: " & bounce.BounceAddress)
ElseIf (bounce.BounceType = 9) Then
' Unsubscribe Request, log the email address
ListBox1.Items.Add("Unsubscribe Request: " & bounce.BounceAddress)
ElseIf (bounce.BounceType = 10) Then
' Virus Notification, log the email address
ListBox1.Items.Add("Virus Notification: " & bounce.BounceAddress)
ElseIf (bounce.BounceType = 11) Then
' Suspected bounce.
' This should be rare. It indicates that the Bounce
' component found strong evidence that this is a bounced
' email, but couldn't quite recognize everything it
' needed to be 100% sure. Feel free to notify
' support@chilkatsoft.com regarding emails having this
' bounce type.
ListBox1.Items.Add("Suspected Bounce!")
End If
email = Nothing
Next
bundle = Nothing
End If
mailman = Nothing
End Sub
Important: The download for this
example does not contain the ChilkatDotNet.dll which |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.