user281812
user281812

Reputation: 195

ASP web site open outlook window

i have asp.net web site with listview populated with products.i add button to listview item for opening outlook new email with product information. the problem is when the new email outlook window is open i cant navigate in my web site until i close the outlook window (it seams like the browser is bussy). is there any way to navigate in the website when outlook window is still open?

ASP:

<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();
    }
}

Upvotes: 0

Views: 1137

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49397

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. You can read more about that in the Considerations for server-side Automation of Office article.

Consider using EWS (Exchange Web Services) in case if you use an Exchange hosted mailbox. See EWS Managed API, EWS, and web services in Exchange for more information.

Upvotes: 2

Related Questions