Sending Email With Outlook

J

John Smith

Hi,

I'm trying to send email in our C# ASP.Net application using the Outlook 11
library. For a bunch of unimportant reasons (unimportant to this posting
that is) we have to do it this way and can't use SMTP.

When I run the application through Visual Studio.Net (by clicking debug in
either debug or release modes), it works fine and the email is sent. When I
run it by going to Internet Explorer directly and typing in my local host
address, the application just hangs and waits when it trys to send the
email. I do hear my machine make that alert noise as if a warning pop up
just opened, but none are there.

Is it not possible to do this? If it is, what do I have to do to so it
doesn't hang when run directly?




If you're curious, here's the code:


Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
oNS.Logon("username", "password", false, true);
//or alternatively:
//oNS.Logon(Missing.Value, Missing.Value, true, true);
Outlook.MailItem oMsg =
(Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
oMsg.Subject = "Testing";
oMsg.HTMLBody = "<HTML><HEAD><TITLE>Sample
GIF</TITLE><BODY><P>Test</P></BODY></HTML>";
Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
Outlook.Recipient oRecip =
(Outlook.Recipient)oRecips.Add("(e-mail address removed)");
oRecip.Resolve();
oMsg.Send();
oNS.Logoff();
 
J

John Smith

Ok....Sorry. Let me clarify.

It works fine if it's ran in Internet Explorer, and it's ran on the machine
that hosts the site.

However, if you try to run it in FireFox, or you try to run it from a
different machine, it does not work.
Just waits and hangs till finally throwing the exception:
System.Runtime.InteropServices.COMException (0x80080005): Server execution
failed

On the server, as soon as the page tries to send an email, the server makes
that ding noise.

I'm sure it's a security or impersonation issue. My question is, can we get
this to work or does the security protection prevent it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top