Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ Delphi FoxPro Java Perl Python Ruby SQL Server VBScript
|
Download and Process Bounced Email
ASP example script to download email from a POP3 mailbox and process bounce (DSN) notifications and other automated email responses. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<%
set mailman = Server.CreateObject("Chilkat.MailMan2")
mailman.UnlockComponent "Anything for 30-day trial"
mailman.MailHost = "mail.chilkatsoft.com"
mailman.PopUsername = "myLogin"
mailman.PopPassword = "myPassword"
set bounce = Server.CreateObject("Chilkat.Bounce")
bounce.UnlockComponent "Anything for 30-day trial"
' Read email from the POP3 server.
Set bundle = mailman.CopyMail()
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
bounce.ExamineMail email
If (bounce.BounceType = 0) Then
Response.Write email.Subject & "<br>"
Response.Write "NOT A BOUNCE<br>"
' Not a bounce, skip it.
ElseIf (bounce.BounceType = 1) Then
' Hard bounce, log the email address
Response.Write email.Subject & "<br>"
Response.Write "Hard Bounce: " & bounce.BounceAddress & "<br>"
ElseIf (bounce.BounceType = 2) Then
' Soft bounce, log the email address
Response.Write email.Subject & "<br>"
Response.Write "Soft Bounce: " & bounce.BounceAddress & "<br>"
ElseIf (bounce.BounceType = 3) Then
' General bounce, no email address available.
Response.Write email.Subject & "<br>"
Response.Write "General Bounce: No email address" & "<br>"
ElseIf (bounce.BounceType = 4) Then
' General bounce, log the email address
Response.Write email.Subject & "<br>"
Response.Write "General Bounce: " & bounce.BounceAddress & "<br>"
ElseIf (bounce.BounceType = 5) Then
' Mail blocked, log the email address
Response.Write email.Subject & "<br>"
Response.Write "Mail Blocked: " & bounce.BounceAddress & "<br>"
ElseIf (bounce.BounceType = 6) Then
' Auto-reply, log the email address
Response.Write email.Subject & "<br>"
Response.Write "Auto-Reply: " & bounce.BounceAddress & "<br>"
ElseIf (bounce.BounceType = 7) Then
' Transient (recoverable) Failure, log the email address
Response.Write email.Subject & "<br>"
Response.Write "Transient Failure: " & bounce.BounceAddress & "<br>"
ElseIf (bounce.BounceType = 8) Then
' Subscribe request, log the email address
Response.Write email.Subject & "<br>"
Response.Write "Subscribe Request: " & bounce.BounceAddress & "<br>"
ElseIf (bounce.BounceType = 9) Then
' Unsubscribe Request, log the email address
Response.Write email.Subject & "<br>"
Response.Write "Unsubscribe Request: " & bounce.BounceAddress & "<br>"
ElseIf (bounce.BounceType = 10) Then
' Virus Notification, log the email address
Response.Write email.Subject & "<br>"
Response.Write "Virus Notification: " & bounce.BounceAddress & "<br>"
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.
Response.Write email.Subject & "<br>"
Response.Write "Suspected Bounce!" & "<br>"
End If
Response.Write "<br>"
Set email = Nothing
Next
Set bundle = Nothing
Else
Response.Write mailman.LastErrorHtml
End If
Set mailman = Nothing
%>
</body></html>
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.