Add the default outlook signature in the email generated

前端 未结 11 463
甜味超标
甜味超标 2020-12-08 07:11

I am using the Microsoft.Office.Interop.Outlook.Application to generate an email and display it on the screen before the user can send it. The application is a

11条回答
  •  借酒劲吻你
    2020-12-08 08:05

    I have got around the problem by mainly being 'sneaky'. If, when you make a new email in Outlook by Ctrl+N, it inserts the default signature, I store that blank email (with signature) in a temporary string then append that string to another string that has the content in it.

    Here is some code to demonstrate it:

    string s = "";
    Outlook.Application olApp = new Outlook.Application();
    Outlook.MailItem mail = olApp.CreateItem(Outlook.OlItemType.olMailItem);
    
    mail.To = "Hi@World.com";
    mail.Subject = "Example email";
    
    s = mainContentAsHTMLString + mail.HTMLBody;
    
    mail.Display();
    mail.HTMLBody = s;
    

提交回复
热议问题