( Index )
Month

Brief Information about the April '09 CSIG Meeting

The BMailer Evolution and other reviews.
B. Arnold

Bulk eMailer Logic

Welcome to the CSIG, a Special Interest Group of the ACGNJ. This is an exciting time for the C Language programming since Microsoft now has 4 different language compilers: C++, C++ Express, C-Sharp, and C-Sharp Express. These are all capable of creating Windows (tm) programs. (See the Random Access section below for an extra topic about Filtering and how the Tracking Reference syntax helps in C++ .Net CLI.)

There have been so many additions to the code and functionality of the BMailer Application presented earlier this year that I wanted to bring everyone up to date with the new features discussed at last Friday's Window Pains meeting, Click Here for a PDF, as well as the new code that created the improvements.

The main focus of the meeting will be the code which handles the SMTP communication. This includes embedding objects, html, multiple attachments, and error handling. This will be the most technically rigorous meeting of the year. You should review past issues of the Bmailer code to get the most out of it. Also the above PDF file. There are also numerous graphical additions to the program that are included in the new code. Some of these will be discussed as interest warrants.

The idea is to create an application that will send out emails in a batch process. It's called "Bmailer" which is short for "Bulk e-Mailer". The program takes as input two previously prepared files. The first is a text file with a list of the recipients email addresses. The list could be hundreds of addresses long. The second is a template text file that will be sent to each recipient.

When the "Send Mail" button is clicked, the application starts sending out the emails to the given SMTP provider. Since some providers don't allow high speed batch processing, an optional 30 second delay is provided between outputs.


There are a number of ways to refer to Microsoft's latest compilers and code. Here's what Wikipedia says: The Common Language Infrastructure (CLI) is an open specification developed by Microsoft that describes the executable code and runtime environment that form the core of the Microsoft .NET Framework. The specification defines an environment that allows multiple high-level languages to be used on different computer platforms without being rewritten for specific architectures.

Microsoft .Net Framework 3.5
C++ 9.0
.Net 3.5
CLI
Common Language Infrastructure
Managed

Sample Code

SMTP Error Responses 1. The SMTP service is closing the transmission channel. 2. The user mailbox is not located on the receiving server; the server forwards the e-mail. 3. The specified user is not local, but the receiving SMTP service accepted the message and attempted to deliver it. This status code is defined in RFC 1123, which is available at http://www.ietf.org. 4. The SMTP service is not available; the server is closing the transmission channel. 5. The destination mailbox is in use. 6. The SMTP service cannot complete the request. This error can occur if the client's IP address cannot be resolved (that is, a reverse lookup failed). You can also receive this error if the client domain has been identified as an open relay or source for unsolicited e-mail (spam). For details, see RFC 2505, which is available at http://www.ietf.org. 7. The SMTP service does not have sufficient storage to complete the request. 8. The client was not authenticated or is not allowed to send mail using the specified SMTP host. 9. The SMTP service does not recognize the specified command. 10. The syntax used to specify a command or parameter is incorrect. 11. The SMTP service does not implement the specified command. 12. The commands were sent in the incorrect sequence. 13. The SMTP server is configured to accept only TLS connections, and the SMTP client is attempting to connect by using a non-TLS connection. The solution is for the user to set EnableSsl=true on the SMTP Client. 14. The SMTP service does not implement the specified command parameter. 15. The destination mailbox was not found or could not be accessed. 16. The user mailbox is not located on the receiving server. You should resend using the supplied address information. 17. The message is too large to be stored in the destination mailbox. 18. The syntax used to specify the destination mailbox is incorrect. 19. The transaction failed. 20. The transaction could not occur. You receive this error when the specified SMTP host cannot be found.
// // Call the Mail Send function with exception handling 1140 // int DoSendMailExecute(SmtpClient ^ mc, MailMessage ^ message, String ^ toArg) { int returnCode = 1; // error try 1145 { mc->Send(message); //MessageBox::Show("Message sent."); returnCode = 0; } catch (SmtpException ^ex) 1150 { if (ErrorStop->Checked) MessageBox::Show(ex->Message, "SMTP"); // Ver 1.24 DisplaySmtpStatus(ex->StatusCode); LogErrorAdd(toArg); } 1155 catch ( SmtpFailedRecipientsException^ ex ) { for ( int i = 0; i < ex->InnerExceptions->Length; i++ ) { SmtpStatusCode status = ex->InnerExceptions[ i ]->StatusCode; if ( status == SmtpStatusCode::MailboxBusy || status == SmtpStatusCode::MailboxUnavailable ) { System::Threading::Thread::Sleep( 5000 ); // Delivery failed - retrying in 5 seconds. mc->Send( message ); returnCode = 0; // What about infinite recursion? This is Msoft code. } else { if (ErrorStop->Checked) MessageBox::Show(ex->InnerExceptions[ i ]->Message, "_SMTP"); // Ver 1.24 DisplaySmtpStatus(ex->InnerExceptions[ i ]->StatusCode); LogErrorAdd(toArg); } } } catch ( Exception^ ex ) 1175 { if (ErrorStop->Checked) MessageBox::Show(ex->Message, "_SMTP_"); // Ver 1.24 LogErrorAdd(toArg); } finally 1180 { if (&mc != 0) { mc-> ~SmtpClient(); } 1185 } return returnCode; }

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page