Saturday, March 21, 2015

Send mail using Outlook and .oft templates

There is already a page for sending mail using Outlook library.
Now this small code is a small tweak i.e. using Outlook Template (*.oft) file.

If you see the code there is hardly any complication but this exercise is time consuming as a whole.
It is because defining the different mail templates takes a lot of time from business POV.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Outlook = Microsoft.Office.Interop.Outlook;

namespace emailTemplateTest {
 class Program {
  static void Main(string[] args) {
   try {
    Outlook.Application otApp = new Outlook.Application(); // create outlook object
    Outlook.NameSpace ns = otApp.Session;
    Outlook.Folder folder = otApp.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts) as Outlook.Folder;
    Outlook.MailItem otMsg = otApp.CreateItemFromTemplate(@ "d:\a2.oft", folder) as Outlook.MailItem; // Open the mail template
    Outlook.Inspector oInspector = otMsg.GetInspector;
    Outlook.Recipient otRecip = (Outlook.Recipient) otMsg.Recipients.Add("Temp@hotmail.com");
    if (otRecip.Resolve()) // validate recipient address
    {
     // Modify the body text as required
     otMsg.Send(); // Send Mail
     otRecip = null;
     otMsg = null;
     otApp.Quit();
    }
   } catch (Exception e) {
    Console.WriteLine("{0} Exception caught: ", e);
   }
  }
 }
}

32 comments:

  1. Raipur girls welcoming you to making you relax and happy by their top class physical services, and at the same time the independent Raipur Escorts are available at you reasonable price.
    http://www.raipurescort.com

    Raipur Escorts

    Raipur Escort

    Raipur Escorts service

    Raipur Escorts Agency

    Independent Raipur Escorts

    Independent Raipur Escort

    Raipur Escorts Girl

    Escorts in Raipur

    Escorts Service in Raipur

    ReplyDelete
  2. Welcome to High Class Surat Escorts Service, the luxurious Surat Escort Services where you can find the most beautiful Escort Sexy and Hot Call girls in Surat and Other Citys Best Escort Services in India.

    Surat Call Girl, Surat Escorts Service

    Surat Call Girls, Surat Escorts

    Call Girls in Surat, Surat Escort

    Surat Escorts, Call Girl in Surat

    Surat Escorts, Surat Escort Service

    ReplyDelete
  3. Mumbai Escorts sillky.in Do not be shy, tell your wish to me, experience-your objectives and should be to the really ecstasy that's me, the usually, the one, for you in here I will be a little, table beauty with awesome perspective, prolonged black smooth locks and interest that is hypnotic.
    Mumbai Escorts, Independent Mumbai Escorts http://sillky.in
    Mumbai Escorts Service, Mumbai Escort http://www.dimpy.in
    Mumbai Call Girl, Call Girls in Mumbai http://www.mumbaicallgirlservice.com
    Call Girl in Mumbai, Mumbai Call Girls http://www.callgirlservicemumbai.com
    Mumbai Escorts, Mumbai Call Girl Service http://www.callgirlinmumbaiescorts.com
    Mumbai Escorts, Mumbai Call Girls http://www.mumbaiescortss.biz
    Call Girl in Mumbai, Call Girls Service in Mumbai http://www.mumbaiescortscallgirl.com
    Mumbai Escorts, Call Girls in Mumbai http://www.meghnakaur.com

    ReplyDelete
  4. Welcome to High Class Surat Escorts Service, the luxurious Surat Escort Services where you can find the most beautiful Escort Sexy and Hot Call girls in Surat and Other Citys Best Escort Services in India.

    Visit The Site For More Details -: http://www.anuroy.com/

    Chennai Escorts, Chennai Call Girls

    Chennai Call Girl, Chennai Escorts Service

    Call Girls Chennai, Chennai Escort

    Chennai Escorts, Chennai Escorts Service

    Call Girls in Chennai, Chennai Escort

    ReplyDelete
  5. Nice And Informative Website. Please Keep Continue Such Kind Of Effort. I Shared Your Post With My Friends Also. I Run My Independent Mumbai Escorts Service. I Provide You High Class Mumbai Models And Beautiful Mumbai Call Girls. We Are Available To Serve You 24 X 7. For Booking Contact With Priya Singh Ph- 09987215552
    Wensite : http://www.escortagencyinmumbai.com/
    mumbai escorts service
    mumbai escorts
    mumbai escort service
    escort service in Mumbai
    mumbai call girls
    Andheri escorts
    Bandra escorts

    ReplyDelete
  6. mumbai escort provided beautiful modal,college girls for you.we have Independent Models, college girls for your Beautiful night
    mumbai escort

    ReplyDelete
  7. we are provided escort service in Mumbai 24 for hours with full arguments, our escorts all type services available for the unlimited time full enjoyment of our independent escort service in Mumbai

    Mumbai escort service

    Escort service in Mumbai

    independent escorts service in Mumbai

    Mumbai independent escorts

    Call girls in Mumbai

    Mumbai Call girls

    escorts service in Andheri

    Andheri escorts service

    ReplyDelete
  8. Udaipur call girls
    independent udaipur escorts
    escorts in udaipur
    Udaipur escorts service
    We are top service provider established in Udaipur city. There are many companion girl in Udaipur. But our girls fully educated and hot they know all the needs who want to need a man with her.

    ReplyDelete
  9. You can ask that closeness fulfillment what you lack from any woman yet. Each one of the three holes of her is reliably start for you with totally satisfying closeness delight. Typically consider any sex-related accepted and recognize it with our eye-getting Chandigarh Escorts.

    Chandigarh Escorts
    Chandigarh Escorts Service
    Escorts in Chandigarh

    ReplyDelete
  10. It is an extensive variety of data brings you towards the best one that would assistance be able to you satisfy your dreams. Albeit, numerous are there to have enough enthusiasm for meeting every one of your desires however certainly everybody has diverse.

    Noida Escorts
    Noida Escorts Services
    Escorts in Noida

    ReplyDelete
  11. It is center to numerous superb and appealing escort women as there is no insufficiency of amazing deceivability of appeal world there. That is the reason looking an appeal toy in the town isn't a testing procedure for anybody; the every one of the one need is simply to arrange bolster elements of an escort Agra with the individual details.

    Agra Escorts
    Agra Escorts Service
    Agra Escort

    ReplyDelete
  12. Our Chandigarh Escorts Service isn't for the people who are consistently hunting down recompenses and more since that are just particularly less than ideal. We simply offer administrations to our clients who are not easygoing about it and who require satisfaction in their life.

    Chandigarh Escorts
    Chandigarh Escorts Service
    Escort Service in Chandigarh

    ReplyDelete
  13. High class escorts in Chandigarh cherish working separately and going by to their customers all alone level and getting the administration charges straightforwardly from their customers to keep their full procuring. Along these lines, plainly free escorts are living better life in contrast with the individuals.

    Chandigarh Escorts
    Chandigarh Escorts Services
    Escorts in Chandigarh

    ReplyDelete
  14. The request of master and very much prepared escorts is expanding step by step in metro urban areas so that in Noida. I am absolutely eager about the Noida escorts girls gave by for you. One of our clients showed that he got the ever best sexual involvement with our friend woman.

    http://www.hunny.co.in/
    http://www.noidaescort.com/
    http://www.noida-escorts.co.in/
    http://www.feelofhaven.in/
    http://www.lovedesire.in/
    http://www.noidaescorts.ind.in/
    http://www.noidaescorts.net.in/

    ReplyDelete
  15. They need aid further separated under Different types: model, airhostess, camera person and so on. Though photography may be your pastime afterward this kind from claiming will make a perfect one sets for you. escorts service in mumbai
    Call Girls Mumbai
    andheri escorts
    mumbai call girls services
    mumbai escorts
    andheri escorts service
    wadala call girls
    vashi call girls
    mumbai call girls services

    ReplyDelete