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
Solution for Bounced EmailDownload: Chilkat .NET Assemblies C# sample source code showing how to create a bounced mail handler. private void button1_Click(object sender, System.EventArgs e)
{
// 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.
Chilkat.MailMan mailman = new Chilkat.MailMan();
mailman.UnlockComponent("MailUnlockCode");
mailman.MailHost = "mail.chilkatsoft.com";
mailman.PopUsername = "login";
mailman.PopPassword = "password";
Chilkat.Bounce bounce = new Chilkat.Bounce();
bool success = bounce.UnlockComponent("BounceUnlockCode");
if (!success)
{
textBox1.Text = bounce.LastErrorText;
return;
}
// Read email from the POP3 server.
Chilkat.EmailBundle bundle;
bundle = mailman.CopyMail();
if (bundle != null)
{
// Loop over each email...
Chilkat.Email email;
int i;
bool success;
for (i=0; i<bundle.MessageCount; i++)
{
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)
listBox1.Items.Add("Failed to classify email");
else if (bounce.BounceType == 1)
// Hard bounce, log the email address
listBox1.Items.Add("Hard Bounce: " + bounce.BounceAddress);
else if (bounce.BounceType == 2)
// Soft bounce, log the email address
listBox1.Items.Add("Soft Bounce: " + bounce.BounceAddress);
else if (bounce.BounceType == 3)
// General bounce, no email address available.
listBox1.Items.Add("General Bounce: No email address");
else if (bounce.BounceType == 4)
// General bounce, log the email address
listBox1.Items.Add("General Bounce: " + bounce.BounceAddress);
else if (bounce.BounceType == 5)
// Mail blocked, log the email address
listBox1.Items.Add("Mail Blocked: " + bounce.BounceAddress);
else if (bounce.BounceType == 6)
// Auto-reply, log the email address
listBox1.Items.Add("Auto-Reply: " + bounce.BounceAddress);
else if (bounce.BounceType == 7)
// Transient (recoverable) Failure, log the email address
listBox1.Items.Add("Transient Failure: " + bounce.BounceAddress);
else if (bounce.BounceType == 8)
// Subscribe request, log the email address
listBox1.Items.Add("Subscribe Request: " + bounce.BounceAddress);
else if (bounce.BounceType == 9)
// Unsubscribe Request, log the email address
listBox1.Items.Add("Unsubscribe Request: " + bounce.BounceAddress);
else if (bounce.BounceType == 10)
// Virus Notification, log the email address
listBox1.Items.Add("Virus Notification: " + bounce.BounceAddress);
else if (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.
listBox1.Items.Add("Suspected Bounce!");
email = null;
}
bundle = null;
}
mailman = null;
}
}
|
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.