Click here to Skip to main content
13,089,618 members (49,166 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


11 bookmarked
Posted 2 Jun 2008

Sending messages by email and Microsoft Office Communicator 2005

, 2 Jun 2008
Rate this:
Please Sign up or sign in to vote.
Save time sending massive messages.


This program tries to make your life easier when you're at work. Every time you want to go on break time, you would have to type emails or add a lot of contacts to a conversation to say: "let's go and have a coffee!" Now, only with a double click, this program does it for you.


The message sender is based on the article: "Automate key sequences for repetitive tasks, reference XML data". With very little changes, you can improve it to reach the objective. So, please read SathishVJ's article before reading this, so you can understand the changes I have done.

Using the code

The application reads from a text file named emails.txt, where you include the emails of the people in your company. You have to list each email in one line without separating them with a comma. The first line is read and it opens a new messenger conversation. Then, the following emails are added into the conversation. Using the SendKeys function, the program takes control of the messenger and writes the message you want to your workmates.

string destinatario = "";

public bool LoadKeySequence() 
    ArrayList keySequenceArray = new ArrayList();

    StreamReader sr = new StreamReader(@"emails.txt");
    String line;
    if ((line = sr.ReadLine()) != null) 
        line = line.Trim();
        //Opens new conversation
        destinatario += line;
        while ((line = sr.ReadLine()) != null)
            destinatario += ",";
            line = line.Trim();
            //Add to conversation
            //Email receivers list separated by comma
            destinatario = destinatario+ line;
        keySequenceArray.Add("Let's have a break and a coffee");
        keySequenceArray.Add("Auto message!!!");

    this.sendKeysSequence = (string[])keySequenceArray.ToArray(typeof(string));
    return true;

Now, I'm going to explain how to send the emails:

string asunto = "BREAK TIME";
string body = "Don't answer to this email. Let's meet at the office door!!!!";

private void mandarEmails()
    //Write your company SMTP server.
    string servidor = "company.smtp.server";
    string html = "";
    // Write who's sending the email and the receivers of your email 
    MailMessage message = new MailMessage("",destinatario);
    // You can write what ever you want in the email and put your signature
    message.IsBodyHtml = true;
    html += @"<html><head> … ";
    html += @" … </head></html>";
    System.Text.StringBuilder messageBody = new System.Text.StringBuilder();
    message.Body = messageBody.ToString();
    message.BodyEncoding = System.Text.Encoding.UTF8;
    message.Subject= asunto;
    SmtpClient cliente = new SmtpClient(servidor);
    //Add credentials to the server
    cliente.Credentials = CredentialCache.DefaultNetworkCredentials;
    //Here you send the email 
    catch (System.Net.Mail.SmtpException ex)


In MainForm(), you have to specify the process you want to open, in this case, it is communicator.exe:

System.Diagnostics.Process p= new System.Diagnostics.Process();
p.StartInfo.FileName = @"communicator.exe";

In main():

static void Main()
     MainForm brum = new MainForm();

This is the important part:

private void arranca()
    if (!this.LoadKeySequence())
     //Find process handle 
    if (!this.FindProcess())
    if (this.noDataFilesRequiredCheckBox.Checked)
        //call other method 
        for (int i = 0; i< this.repeatCountNumericUpDown.Value; i++)
    MessageBox.Show("I have sent everything!!");


Finally, set thse in the MainForm.cs design interface:

  • keySequenceFileTextBox.Text= Path where the file "emails.txt" is.
  • targetAppTitleTextBox.Text= Microsoft Office Communicator

And your program is finished and ready to run!! Have fun with it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Mikel A. Rodriguez
Spain Spain
I have studied Telecommunication engineering at the Public University of Navarra. Now working in Business Intelligence as an analyst consultant in TIC projects.

You may also be interested in...

Comments and Discussions

GeneralDoesn't compile Pin
DumpsterJuice2-Jun-08 9:27
memberDumpsterJuice2-Jun-08 9:27 
GeneralRe: Doesn't compile Pin
Mikel A. Rodriguez3-Jun-08 1:09
memberMikel A. Rodriguez3-Jun-08 1:09 
GeneralRe: Doesn't compile Pin
DumpsterJuice3-Jun-08 1:48
memberDumpsterJuice3-Jun-08 1:48 
GeneralRe: Doesn't compile Pin
Mikel A. Rodriguez3-Jun-08 3:03
memberMikel A. Rodriguez3-Jun-08 3:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170813.1 | Last Updated 2 Jun 2008
Article Copyright 2008 by Mikel A. Rodriguez
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid