Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
Identify Bounced and Automated Email Messages
Visual Foxpro example to download email from a POP3 server and determine if each email is an automated message or bounce. * NOTE: If you find syntactical errors in this example, or have any trouble,
* please notify us at support@chilkatsoft.com.
* 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.
LOCAL mailman, bounce, bundle, email, success, summary
mailman = CreateObject('Chilkat.MailMan2')
mailman.UnlockComponent('MailUnlockCode')
mailman.MailHost = 'mail.chilkatsoft.com'
mailman.PopUsername = 'myLogin'
mailman.PopPassword = 'myPassword'
bounce = CreateObject('Chilkat.Bounce')
bounce.UnlockComponent('BounceUnlockCode')
* Read email from the POP3 server.
bundle = mailman.CopyMail()
* Your program should check to see if bundle is .NULL., and if so then
* the last-error information in mailman.LastErrorText is helpful in determining
* the cause of the failure. You may also call mailman.SaveLastError.
summary = ""
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
bounce.ExamineMail(email)
DO CASE
CASE (bounce.BounceType = 0)
* Not a bounce, skip it.
CASE (bounce.BounceType = 1
* Hard bounce, log the email address
summary = summary + email.Subject + + CHR(13)+CHR(10)
summary = summary + "Hard Bounce: " + bounce.BounceAddress + CHR(13)+CHR(10)
CASE (bounce.BounceType = 2)
* Soft bounce, log the email address
summary = summary + email.Subject + + CHR(13)+CHR(10)
summary = summary + "Soft Bounce: " + bounce.BounceAddress + CHR(13)+CHR(10)
CASE (bounce.BounceType = 3)
* General bounce, no email address available.
summary = summary + email.Subject + + CHR(13)+CHR(10)
summary = summary + "General Bounce: No email address" + CHR(13)+CHR(10)
CASE (bounce.BounceType = 4)
* General bounce, log the email address
summary = summary + email.Subject + + CHR(13)+CHR(10)
summary = summary + "General Bounce: " + bounce.BounceAddress + CHR(13)+CHR(10)
CASE (bounce.BounceType = 5)
* Mail blocked, log the email address
summary = summary + email.Subject + + CHR(13)+CHR(10)
summary = summary + "Mail Blocked: " + bounce.BounceAddress + CHR(13)+CHR(10)
CASE (bounce.BounceType = 6)
* Auto-reply, log the email address
summary = summary + email.Subject + + CHR(13)+CHR(10)
summary = summary + "Auto-Reply: " + bounce.BounceAddress + CHR(13)+CHR(10)
CASE (bounce.BounceType = 7)
* Transient (recoverable) Failure, log the email address
summary = summary + email.Subject + + CHR(13)+CHR(10)
summary = summary + "Transient Failure: " + bounce.BounceAddress + CHR(13)+CHR(10)
CASE (bounce.BounceType = 8)
* Subscribe request, log the email address
summary = summary + email.Subject + + CHR(13)+CHR(10)
summary = summary + "Subscribe Request: " + bounce.BounceAddress + CHR(13)+CHR(10)
CASE (bounce.BounceType = 9)
* Unsubscribe Request, log the email address
summary = summary + email.Subject + + CHR(13)+CHR(10)
summary = summary + "Unsubscribe Request: " + bounce.BounceAddress + CHR(13)+CHR(10)
CASE (bounce.BounceType = 10)
* Virus Notification, log the email address
summary = summary + email.Subject + + CHR(13)+CHR(10)
summary = summary + "Virus Notification: " + bounce.BounceAddress + CHR(13)+CHR(10)
CASE (bounce.BounceType = 11)
* 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.
summary = summary + email.Subject + + CHR(13)+CHR(10)
summary = summary + "General Bounce: No email address" + CHR(13)+CHR(10)
OTHERWISE
* This is not expected...
summary = summary + email.Subject + + CHR(13)+CHR(10)
summary = summary + "UNEXPECTED!" + CHR(13)+CHR(10)
ENDCASE
RELEASE email
NEXT
RELEASE mailman, bundle, bounce
=MESSAGEBOX(summary)
RETURN .T.
|
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.
Mail Component · .NET Email Component · ASP Mail Component · XML Parser