C# ASP.NEt calling Outlook Interop

J

Joey Lee

Hi,

I am trying to send mail thru outlook. I have found some code on the web and
ws trying it out. I was successful in creating a mail in the draft folder of
outlook, however hangs for a long time during the sending of the mail.

Snippet code as below
-------------------------------------------

using Outlook = Microsoft.Office.Interop.Outlook; //using the 11.0 object
library

private Outlook.Application oApp = null;
private Outlook.NameSpace oNameSpace = null;
private Outlook.MAPIFolder oOutboxFolder = null;

oApp = new Outlook.Application();
oNameSpace= oApp.GetNamespace("MAPI");
oNameSpace.Logon(null,null,true,true);
oOutboxFolder =
oNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox);

Outlook.MailItemClass mi =
(Outlook.MailItemClass)oApp.CreateItem(Outlook.OlItemType.olMailItem);
mi.To = "(e-mail address removed)";
mi.Body = "Some Message";
mi.Subject = "Some Title";
mi.SaveSentMessageFolder = oOutboxFolder;
mi.Save(); //works where i am able to see the mail in the draft folder
mi.Send(); //does not execute where the web page just stalls

-------------------------------------------------

Any help why this is happening, if the save() works, why does the send just
stalls and does not drop a mail in the outbox for sending.

Is there any settings on the server side which i miss?

I am running everything below on the same pc :-
Windows Server 2003 Enteprise Ed
..NET 1.1 Framework
MS IIS 6
MS Exchange 2003
Office 2003(Outlook 2003 and etc)

Thanks,

Joey
 
G

Guest

Just a guess, but when using the Outlook Interop in this way you must give it
explicit commands. It's possible that you're sending the mail item to the
outbox with send, but not performing a send/receive.

Any reason you didn't just use the SMTP class???

Ryan
 

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,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top