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
[quoted text, click to view] "Joey Lee" wrote:
> 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 = "test@test.com";
> 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
>
>