开发者

Silverlight 4 Email AutomationFactory.CreateObject throws exception

I am trying to launch Outlook from a Silverlight 4 application. I referred this article. But the code throws exception as "This operation is not supported in the current context."

Please suggest what needs to be done to fix this issue?

using (dynamic outlook = AutomationFactory.CreateObject("Outlook.Application")) 
{
    dynamic mail = outlook.CreateItem(0);
    mail.To = ""; 
    mail.Subject = "Hello, from Sil开发者_Go百科verlight";
    mail.HTMLBody = "";
    mail.Display(); 
}


Is your application running Out of Browser? Is it running as a Trusted Application (you checked the "Require elevated trust" checkbox in the OOB settings window)? Is this code running on Windows?

AutomationFactory is only usable of all three answers above are "yes". To verify that everything is as it should be, you should check that AutomationFactory.IsAvailable is true before calling any other AutomationFactory APIs. This has the bonus that your code can easily detect when that functionality will not be available to either warn the user, fall back to other behavior, or not show the option in the UI at all.

Also, to verify the hopefully-obvious: does the machine this is running on have Outlook installed?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜