【问题标题】:ASP web site open outlook windowASP 网站打开 Outlook 窗口
【发布时间】:2015-03-26 07:26:26
【问题描述】:

我有一个带有产品列表视图的 asp.net 网站。我向列表视图项目添加按钮,用于打开带有产品信息的 Outlook 新电子邮件。问题是当新的电子邮件 Outlook 窗口打开时,我无法在我的网站中导航,直到我关闭 Outlook 窗口(它看起来像浏览器很忙)。当 Outlook 窗口仍然打开时,有什么方法可以在网站中导航?

平均售价:

<asp:LinkButton ID="promote_link" runat="server" Text="send with mail" CommandName="mail"/>

C#:

 protected void site_search_results_list_ItemCommand(object sender, ListViewCommandEventArgs e)
{
    Label lblProductId = (Label)e.Item.FindControl("lblProductId");

    if (e.CommandName == "mail")
    {
        Outlook.Application outlookApp = new Outlook.Application();
        Outlook._MailItem mailItem = (Outlook._MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
        mailItem.Subject = "subject";
        mailItem.Display(true);
        outlookApp.Quit();
    }
}

【问题讨论】:

  • 以编程方式在服务器上显示任何 UI 元素是个好主意吗?
  • 有什么替代方案?我希望用户有这个能力。

标签: c# asp.net email outlook


【解决方案1】:

Microsoft 目前不推荐也不支持从任何无人值守的非交互式客户端应用程序或组件(包括 ASP、ASP.NET、DCOM 和 NT 服务)自动化 Microsoft Office 应用程序,因为 Office在此环境中运行 Office 时可能会出现不稳定的行为和/或死锁。

如果您要构建在服务器端上下文中运行的解决方案,您应该尝试使用已确保无人值守执行安全的组件。或者,您应该尝试找到允许至少部分代码在客户端运行的替代方案。如果您使用服务器端解决方案中的 Office 应用程序,该应用程序将缺少许多成功运行所需的功能。此外,您将承担整体解决方案稳定性的风险。您可以在Considerations for server-side Automation of Office 文章中阅读更多相关信息。

如果您使用 Exchange 托管邮箱,请考虑使用 EWS(Exchange Web 服务)。有关更多信息,请参阅EWS Managed API, EWS, and web services in Exchange

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多