如何从2010年的SharePoint打开Outlook撰写新邮件progamaticallly
我需要从SharePoint打开Outlook邮件compaose编程,我想这代码,但它只是打开Outlook的过程,但在撰写邮件窗口没有出现如何从2010年的SharePoint打开Outlook撰写新邮件progamaticallly
using (SPSite currentSite = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb currentWeb = currentSite.OpenWeb(SPContext.Current.Web.ID))
{
WebURL = currentWeb.Url;
currentWeb.AllowUnsafeUpdates = true;
SPList correspondences = currentWeb.Lists.TryGetList("list1");
SPListItem correspondenceItem = correspondences.GetItemById(id);
WebURL = currentWeb.Url;
SPAttachmentCollection CorrespondenceAttachemt = correspondenceItem.Attachments;
Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook._MailItem oMailItem = (Microsoft.Office.Interop.Outlook._MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
oMailItem.Body = body;
oMailItem.Subject = title;
oMailItem.Display();
}
}
该代码正在SharePoint服务器上运行,对吗?在这种情况下,您将在服务器端启动Outlook,而不是客户端。除此之外,Outlook(就像任何其他Office应用程序一样)不能用于服务。
为什么不使用mailto url?
默认情况下oMailItem.Display为False。将其更改为true。
oMailItem.Display (true);
这应该现在工作。
是否与你一起工作? ,我已经尝试过,但仍然无法正常工作,OUTLOOK程序已经在任务管理器中打开,但是Outlook的撰写邮件窗口不是,请注意,我在控制台应用程序中尝试了我的代码,它工作正常 – mahamed 2013-03-28 09:31:41
它为我工作。 – 2013-03-28 12:03:18
是否在Display()方法中添加了'true'参数? – 2013-03-28 12:03:53
你可能会在'oMailItem.Display();'上得到一个异常。尝试在代码上附加断点 – 2013-03-27 11:00:00
是的......错误是“Microsoft Exchange不可用,或者存在网络问题或Exchange服务器因维护而关闭。” – mahamed 2013-03-28 12:24:48