( Index )

Brief Information about the Dec '08 CSIG Meeting

Bulk e-Mailer Application
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.

The newest versions are designated Visual Studio 2008. There are "Express" versions otherwise know as "Free" as well as the commercial versions. The Express versions are fully functional for creating Managed Code. Unless you work in a large program development company, you probably won't need the broader features of the commercial versions. For other companies check the September CSIG page. Also check the October CSIG page for links to some Microsoft C++ What's New information.

This month I will present a program inspired by Mike Redlich at the Java SIG meeting last week. 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 prepaired 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 this compiler 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 2.0
C++ 7.0
.Net 2.0
Common Language Infrastructure

Sample Code

    // Fill the template list box
    void GetTemplate(String ^ filename)
        // Open the file to read from.
        StreamReader ^sr = gcnew StreamReader(filename);
        if (sr != nullptr)
            String ^s;
            while ((s = sr->ReadLine()) != nullptr) 

private: System::Void SendMail_Click(System::Object^  sender, System::EventArgs^  e) {
             timer1->Interval = 1000;
             timer1->Enabled = true;
             SendMail->Enabled = false;
             CurrentRecip = 0;
             SentCount = 0;
             AbortFlag = false;
             Abort->Enabled = true;

private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
             timer1->Enabled = false;
             timer1->Interval = Timer30->Checked ? 30000 : 1000;
             if (CurrentRecip < Recipients->Items->Count)
                Recipients->SetSelected(CurrentRecip, true);
                if ( 0 == DoSendMail() ) ++SentCount;
                SentInfo->Text = String::Format("{0} emails sent.", SentCount);
             if (AbortFlag || (CurrentRecip >= Recipients->Items->Count))
                 SendMail->Enabled = true;
                 timer1->Enabled = true;

Note: typically you will need the MS C++ Redistribution Package to run programs on any computer.

"Random Access" questions start at 7:30 Tuesday night.


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