c_shooter
c_shooter

Reputation: 21

New Outlook mail message doesn't load

I have the following simplified code:

using Outlook = Microsoft.Office.Interop.Outlook;
protected void SendEmailBtn_Click(object sender, EventArgs e)
        {
            Outlook.Application OutlookApp = new Outlook.Application();
            Outlook.MailItem mailItem = (Outlook.MailItem)OutlookApp.CreateItem(Outlook.OlItemType.olMailItem);
            mailItem.Subject = "Test Send Email";
            mailItem.BCC = "[email protected]";
            mailItem.Body = "Dear";
            mailItem.Display(false);
        }

I've installed office 2007 and 2007 PIAs and deployed the code on the server (win2008 server), but when I click on the send button nothing happens on the clients machine the outlook mail message is not created, the page just stays in a loading state, no errors or exceptions are given. Looking at task manager on the server the outlook process does start and is running. The code works fine locally i.e. an outlook mail message is created. I'm not sure what could be causing this to happen, could it be the anti virus on the server blocking file access? Do I need to install something else? Any help would be much appreciated. Thanks.

Upvotes: 2

Views: 502

Answers (1)

JMK
JMK

Reputation: 28069

If all you want to do is to load the message in an outlook window for the user to review and then send themselves I think that using Outlook Interop is overkill. Just use an ordinary hyperlink like so:

<a href="mailto:[email protected]&subject=Test+Send+Email&body=Dear">My Hyperlink</a>

Or in C#:

System.Diagnostics.Process.Start("mailto:[email protected]&subject=Test+Send+Email&body=Dear");

Upvotes: 1

Related Questions