0

I found two ways to create an object of Outlook mailItem

Outlook.MailItem oMsg = (Outlook.MailItem)Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olMailItem);

and

 Outlook.Application oApp = new Outlook.Application();
Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);

What is the diffrence between these two codes and Which one is better and secure?

4

1 回答 1

1

If your code is in a COM addin, the first one is the one and only way to do it - use the Outlok.Application object passed to your addin instead of creating a new instance. COM addins are trusted, and the Outlok.Application object is not crippled by the security prompts.

于 2014-06-02T07:03:47.453 回答