Creating mail message in a specific folder in Outlook

Print Friendly

In one of my Outlook addins I need to place my e-mail messages into a specific folder. In my previous post, I’ve write how to create folders in outlook; I’ve do that with no problem; but the creating e-mails… Infact it should be an easy task to perform, just like below :

Outlook.MailItem mailObject = (Outlook.MailItem)myFolder.Items.Add(Outlook.OlItemType.olMailItem);
mailObject.Subject = "Subject Of my e-mail";
mailObject.To = "reci...@email.com";
mailObject.Body = "Content of my message";
mailObject.Save();

Its working quite good on paper, but not on my computer. Well, an e-mail message has been created, but outlook did save in into the drafts folder. After a google query (SELECT * FROM GOOGLE :) ) I’ve found the answer in Microsoft’s news group. It was all about outlook and its way tomake our life easier (!?). It automatically saves newly created e-mail message into dreafts folder. Another strange thing with it is it does not perform the same action for the other type like notes.Anyway, to overcome this problem, I should perform one more task, I should move it to my folder Here is the final code with no problem:

Outlook.MailItem mailObject = (Outlook.MailItem)myFolder.Items.Add(Outlook.OlItemType.olMailItem);
mailObject.Subject = "Subject Of my e-mail";
mailObject.To = "reci...@email.com";
mailObject.Body = "Content of my message";
mailObject.Save();
mailObject.Move(myFolder);

Related posts:

  1. Creating Folders on Outlook
  2. Outlook’ta bir dizinde mail nesnesi oluşturma
  3. Outlook içerisinde yeni dizin oluşturma
  4. Outlook mail nesnesi içerisine özel alanlar ekleme ve yeni görünüm oluşturma
  5. Changing Team Foundation Server SMTP Server and E-mail Notification Settings
Twitter Digg Delicious Stumbleupon Technorati Facebook Email

No comments yet... Be the first to leave a reply!

Leave a Reply

 
QR Code Business Card