Hi, i am having problems accessing outlook from asp.net.
I create a C# console application which connect to outlook fine however when changing it to work with asp.net it just hangs can someone tell me what it wrong with it.
Thanks
Code
try
{
Outlook.Application oApp = new Outlook.Application();
Outlook.NameSpace oNS = oApp.GetNamespace("mapi");
oNS.Logon(Missing.Value,Missing.Value,false,true);
Outlook.MAPIFolder oInbox = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Items oItems = oInbox.Items;
Outlook.MailItem oMsg = (Outlook.MailItem)oItems.GetFirst();
Console.WriteLine(oMsg.Subject);
Console.WriteLine(oMsg.SenderName);
Console.WriteLine(oMsg.ReceivedTime);
Console.WriteLine(oMsg.Body);
int AttachCnt = oMsg.Attachments.Count;
Console.WriteLine("Attachments: " + AttachCnt.ToString());
oNS.Logoff();
oMsg = null;
oItems = null;
oInbox = null;
oNS = null;
oApp = null;
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught: ", e);
}
Arve Paalsrud - 05 Sep 2004 02:54 GMT
Hi Jon,
Please read this article from Microsoft:
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/s
upport/kb/articles/q237/9/13.asp&NoWebContent=1
- A
> Hi, i am having problems accessing outlook from asp.net.
>
> I create a C# console application which connect to outlook fine however when changing it to work with asp.net it just hangs can someone tell me what
it wrong with it.
> Thanks
>
[quoted text clipped - 43 lines]
>
> <Id>Yu0PvrCZCkuli3Wkn+rdcg==</Id
Tom Rizzo [MSFT] - 13 Sep 2004 22:00 GMT
If you're using Exchange Server, you should use CDO for Exchange or WebDAV
with ASP .NET. The Outlook object model is not safe for server-side apps.
Tom

Signature
Looking for a good book on programming Exchange, Outlook, ADSI and
SharePoint? Check out http://www.microsoft.com/MSPress/books/5517.asp
This posting is provided "AS IS" with no warranties, and confers no rights.
> Hi Jon,
>
[quoted text clipped - 58 lines]
>>
>> <Id>Yu0PvrCZCkuli3Wkn+rdcg==</Id