????????????????????Outlook API???????о???????????????????????(C#???)????Outlook???????????????????????????????д???????????????????????html???????檔???????????£?
?????????д????????????????????
????????????html????
??????????????????????????????????
?????????????????£?
????1. ??????á?
???????? Reference ??? -> COM tab -> Microsoft Outlook 12.0 Object Library.
???????????????б??ж???“System.Office.Interop.Outlook”.
??????????????????“using Microsoft.Office.Interop.Outlook;”.
????2. ?????????

 

# generate email automatically
private string GenerateEmail()
{
# default content of mail?? sender will modify and verify before sending out
string hello = "Hi??<br><br>This is an example for sending automatic email via outlook.<br><br>Thanks??";
# html report that is gennerated automatically
string report = "<html>report content.</html>";
ApplicationClass app = new Microsoft.Office.Interop.Outlook.ApplicationClass();
MailItem mail = (MailItem)app.CreateItem(OlItemType.olMailItem); # create mail object
mail.SendUsingAccount = app.Session.Accounts[1];    # sender
string date = DateTime.Today.Month + "-" + DateTime.Today.Day + "-" + DateTime.Today.Year;    # current date??format “7-10-2013”
mail.Subject = "[" + date + "?? pass] Smoke Test Report";    # email subject
mail.To = "to_1@***.com";    # To list
mail.CC = "cc_1@***.com;cc_2@***.com;";    # cc list
mail.BodyFormat = OlBodyFormat.olFormatHTML;    # email is in html format
mail.HTMLBody = hello + report + ReadSignature();    # email content
mail.Display();    # popup email interface before sending
}