Your program should verify that it does not pass an email address that is empty to the email object’s AddTo method. The AddTo method returns a true/false success value. If a zero-length email address is passed to it, a false value is returned. If you do not check and try to send email to no recipients, you’ll get the error message as described below.
Here is sample C# code that shows how to reproduce this error. The error messages follow:
// The mailman object is used for sending and receiving email.
Chilkat.MailMan mailman = new Chilkat.MailMan();
// Any string argument automatically begins the 30-day trial.
bool success;
success = mailman.UnlockComponent("30-day trial");
if (success != true) {
MessageBox.Show("Component unlock failed");
return;
}
// Set the SMTP server.
mailman.SmtpHost = "smtp.mymailserver.com";
// Create a new email object
Chilkat.Email email = new Chilkat.Email();
email.Subject = "This is a test";
email.Body = "This is a test";
email.From = "Chilkat Support <support@chilkatsoft.com>";
string friendlyName = "Chilkat Support";
string emailAddr = "";
// Pass an empty string for the email address:
success = email.AddTo(friendlyName,emailAddr);
if (success != true) {
MessageBox.Show(email.LastErrorText);
}
// Let's send the email anyway, even though there are no
// valid recipients. We'll get an error....
success = mailman.SendEmail(email);
if (success != true) {
MessageBox.Show(mailman.LastErrorText);
}
else {
MessageBox.Show("Mail Sent!");
}
The email object’s LastErrorText will contain this (immediately after the call to AddTo):
ChilkatLog:
AddTo:
DllDate: Nov 13 2007
name: Chilkat Support
address:
No Email Address was provided
The mailman’s LastErrorText contains the following. Notice that NumSuccess and NumTotal are both 0 — indicating that no recipients were ever added to the email. This is the clue that tells you that AddTo was never called, or if it was, an empty string was passed to it.
ChilkatLog:
SendEmail:
DllDate: Nov 13 2007
Username: Chilkat
Component: Ruby
SMTP_Connect:
Connecting to SMTP server smtp.comcast.net:25
smtp_host: smtp.comcast.net
smtp_port: 25
smtp_user: NULL
trying-auth-method: NONE
InitialResponse: 220 OMTA13.emeryville.ca.mail.comcast.net comcast ESMTP server ready
sendingHello: EHLO CK2007
helloResponse: 250-OMTA13.emeryville.ca.mail.comcast.net hello [66.173.223
.150], pleased to meet you
250-HELP
250-AUTH LOGIN PLAIN CRAM-MD5
250-SIZE 15728640
250-ENHANCEDSTATUSCODES
250-8BITMIME
250-STARTTLS
250 OK
smtpAuthMethod: NONE
login_method: NONE or already authenticated
CONNECTED to ESMTP server smtp.comcast.net:25
Using undisclosed recipients
subject: This is a test
reversePath: support@chilkatsoft.com
NumSuccess: 0
NumTotal: 0
Send failed.