Outlook 2002 & COM

C

Cyril Tiwari

Hi,

I created an aspx page on my local machine that logs the number of
contacts I have in my Outlook 2002 client. (pls see code below)

---------------------------------------------------------------------------
Dim objOutlookApp As Outlook.Application
Dim objOutlookNamespace As Outlook.NameSpace
Dim objContact As Object
Dim objOutlookItems As Outlook.Items
Dim objOutlookItem As Outlook.ContactItem

objOutlookApp = New Outlook.Application()

objOutlookNamespace = objOutlookApp.GetNamespace("mapi")

objContact = objOutlookNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)

objOutlookItems = objContact.Items

Log.writeLog("Num Contacts : " & objOutlookItems.Count())
---------------------------------------------------------------------------

This code works fine, so, I uploaded this code to our staging server,
STAGE_SERV. I created a domain acct called ASPNET and put it in the
administrator's group on STAGE_SERV. Then, I edited the machine.config
file on STAGE_SERV as follows :

-----------------------------------------------------------------------------
(Under the processModel section)
userName="<domain_name>\ASPNET"
assword = "<ASPNET_domain_password>"
-----------------------------------------------------------------------------

Lastly, in gave STAGE_SERV\ASPNET read access to my local Outlook.exe
client.

When I browse to the application on STAGE_SERV, instead of getting the
number of Outlook contacts in my Outlook 2002 client, I get the
following message :

System.Runtime.InteropServices.COMException (0x80080005): Server
execution failed

Any help would be greatly appreciated.

Thanks in advance.
 
D

Dmitry Streblechenko

1. ASPNET user does not have any profiles set up, your ASP code must run in
the same security context as the profile which you want to use
2. Office apps (including Outlook) should never ever be used in a service
(IIS included). CDO 1.21 is fine as long as you connect to an Exchange
server, PST store cannot be used as it can only be accessed by a single MAPI
session.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
C

Cyril Tiwari

Thanks for your reply Dmitry.

I understand that ASPNET does not have any profiles. Other than
attempting to log in as the user with his/her profile, is there
anything else I need to do.

I.e. objOutlookNamespace.Logon("<profile>", "<password>", False, True)

Secondly, can you please explain what you mean when you say that
Office Apps should't be used in a service? To my knowledge, I am not
running anything in a service.

Thanks again.
Cyril Tiwari
 
D

Dmitry Streblechenko

1. There is nothing you can do short of running your ASP code in a user
context that does have profiles. If you are using CDO 1.21, you can create a
temporary profile simply passing the names of an Exchange Server and a
mailbox
2. ASP code is running in the IIS context, which does run as a service.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

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

Top