Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Detect Bounced Email
VBScript showing how to detect a bounced email. set mailman = CreateObject("Chilkat.MailMan2")
mailman.UnlockComponent "Anything for 30-day trial"
mailman.MailHost = "mail.chilkatsoft.com"
mailman.PopUsername = "matt@chilkatsoft.com"
mailman.PopPassword = "myPassword"
set bounce = CreateObject("Chilkat.Bounce")
success = bounce.UnlockComponent("Anything for 30-day trial")
if (success = 0) then
MsgBox bounce.LastErrorText
WScript.Quit
end if
' Read email from the POP3 server.
set bundle = CreateObject("ChilkatMail2.ChilkatEmailBundle2")
Set bundle = mailman.CopyMail()
bounceReport = ""
If (Not (bundle Is Nothing)) Then
' Loop over each email...
For i = 0 To bundle.MessageCount - 1
Set email = bundle.GetEmail(i)
' See if this is a bounced email.
' This sets the properties of the Bounce object
success = bounce.ExamineMail(email)
if (success = 0) then
MsgBox bounce.LastErrorText
WScript.Quit
end if
If (bounce.BounceType = 0) Then
' Not a bounce, skip it.
ElseIf (bounce.BounceType = 1) Then
' Hard bounce, log the email address
bounceReport = bounceReport & email.Subject & vbCrLf
bounceReport = bounceReport & "Hard Bounce: " & bounce.BounceAddress & vbCrLf
ElseIf (bounce.BounceType = 2) Then
' Soft bounce, log the email address
bounceReport = bounceReport & email.Subject & vbCrLf
bounceReport = bounceReport & "Soft Bounce: " & bounce.BounceAddress & vbCrLf
ElseIf (bounce.BounceType = 3) Then
' General bounce, no email address available.
bounceReport = bounceReport & email.Subject & vbCrLf
bounceReport = bounceReport & "General Bounce: No email address" & vbCrLf
ElseIf (bounce.BounceType = 4) Then
' General bounce, log the email address
bounceReport = bounceReport & email.Subject & vbCrLf
bounceReport = bounceReport & "General Bounce: " & bounce.BounceAddress & vbCrLf
ElseIf (bounce.BounceType = 5) Then
' Mail blocked, log the email address
bounceReport = bounceReport & email.Subject & vbCrLf
bounceReport = bounceReport & "Mail Blocked: " & bounce.BounceAddress & vbCrLf
ElseIf (bounce.BounceType = 6) Then
' Auto-reply, log the email address
bounceReport = bounceReport & email.Subject & vbCrLf
bounceReport = bounceReport & "Auto-Reply: " & bounce.BounceAddress & vbCrLf
ElseIf (bounce.BounceType = 7) Then
' Transient (recoverable) Failure, log the email address
bounceReport = bounceReport & email.Subject & vbCrLf
bounceReport = bounceReport & "Transient Failure: " & bounce.BounceAddress & vbCrLf
ElseIf (bounce.BounceType = 8) Then
' Subscribe request, log the email address
bounceReport = bounceReport & email.Subject & vbCrLf
bounceReport = bounceReport & "Subscribe Request: " & bounce.BounceAddress & vbCrLf
ElseIf (bounce.BounceType = 9) Then
' Unsubscribe Request, log the email address
bounceReport = bounceReport & email.Subject & vbCrLf
bounceReport = bounceReport & "Unsubscribe Request: " & bounce.BounceAddress & vbCrLf
ElseIf (bounce.BounceType = 10) Then
' Virus Notification, log the email address
bounceReport = bounceReport & email.Subject & vbCrLf
bounceReport = bounceReport & "Virus Notification: " & bounce.BounceAddress & vbCrLf
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.
bounceReport = bounceReport & email.Subject & vbCrLf
bounceReport = bounceReport & "Suspected Bounce!" & vbCrLf
End If
Next
MsgBox bounceReport
Else
MsgBox mailman.LastErrorText
End If
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2003-2007 Chilkat Software, Inc. All Rights Reserved.