469,572 Members | 1,189 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

Reading the Exchange GAL from asp.net page

Hi.

I am trying to read addresses from an Exchange 5.5 Global
Address Book from an asp.net page. When the page executes
the error "Collaboration Data Objects - [E_FAIL
(80004005)]]" is generated.

Here is the code:

Dim strProfileInfo As String
Dim ObjSession As New MAPI.Session
Dim objAddressListType As New
MAPI.CdoAddressListTypes
Dim objAddressList As New Object
Dim objAddressEntry As New Object

Dim strServer As String = "" - valid server
name here
Dim strMailbox As String = "" - valid mailbox
here
strProfileInfo = strServer & vbLf & strMailbox
ObjSession.Logon(, , False, True, , True,
strProfileInfo)

objAddressList = ObjSession.GetAddressList
(objAddressListType.CdoAddressListGAL)

'list all addresses in the gal
For Each objAddressEntry In objAddressList
Response.Write(objAddressEntry.Address())
Next

The ObjSession.GetAddressList method call is the line
that generates the error.

We are running Exchange 5.5. I am using CDO version
1.21. The web server and the exchange server are two
different machines. The web server, which is my localhost
for now, is running XP.

I would be thankfull for any help.

Thanks.

Jeff

Jul 21 '05 #1
7 10326
Hi Jeff,

You may have a test with the steps below.
1) open a new ASP file.

2) Cut and paste the following code in it.

3) Modify the serve r name and Profile name to reflect your own. ( place
where to change is in red and bold )

4) Change the recepient name to your own. ( place where to change is in red
and bold )

5) Save file as testmail.asp

Load file in browser and try it.

------------------------------------CODE
BEGIN----------------------------------

<%@ LANGUAGE="VBSCRIPT" %>

<%

Fetch = Request.Form.Item("Fetch")

if Fetch = "Fetch" then

Set objSession = CreateObject("MAPI.Session")

bstrServer = "YourServerName"

bstrMailbox = "YourProfileName"

bstrProfileInfo = bstrServer + vbLf + bstrMailbox

objSession.Logon , , , false, , true, bstrProfileInfo

' create a message and fill in its properties

Set objMessage = objSession.Outbox.Messages.Add

objMessage.Subject = "test message"

objMessage.Text = "test message"

' create the recipient

Set objOneRecip = objMessage.Recipients.Add

objOneRecip.Name = "YourName" ' example Rohit Puri if I was sending it to
myself

objOneRecip.Resolve ' get MAPI to determine complete e-mail address

' send the message and log off

objMessage.Send showDialog=false

objSession.Logoff

set objSession = nothing

set objMessage = nothing

set objOneRecip = nothing

end if

%>

<html>

<body>

<form action="testmail.asp" method="post" id=form>

<input id="Fetch" name="Fetch" type="submit" value="Fetch">

</p>

</form>

</body>

</html>

Please have a test and let me know the result.
What is the authentication in the IIS you are using, if it is the windows
intergrated authentication, try to change it into basic authentication.
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
Content-Class: urn:content-classes:message
From: "jeff" <je********@infarmbureau.com>
Sender: "jeff" <je********@infarmbureau.com>
Subject: Reading the Exchange GAL from asp.net page
Date: Tue, 7 Oct 2003 12:30:39 -0700
Lines: 48
Message-ID: <03****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcONCX1uvF5A55y+Rn+WDMBKFVcCQw==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Newsgroups: microsoft.public.dotnet.general
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:111091
NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
X-Tomcat-NG: microsoft.public.dotnet.general

Hi.

I am trying to read addresses from an Exchange 5.5 Global
Address Book from an asp.net page. When the page executes
the error "Collaboration Data Objects - [E_FAIL
(80004005)]]" is generated.

Here is the code:

Dim strProfileInfo As String
Dim ObjSession As New MAPI.Session
Dim objAddressListType As New
MAPI.CdoAddressListTypes
Dim objAddressList As New Object
Dim objAddressEntry As New Object

Dim strServer As String = "" - valid server
name here
Dim strMailbox As String = "" - valid mailbox
here
strProfileInfo = strServer & vbLf & strMailbox
ObjSession.Logon(, , False, True, , True,
strProfileInfo)

objAddressList = ObjSession.GetAddressList
(objAddressListType.CdoAddressListGAL)

'list all addresses in the gal
For Each objAddressEntry In objAddressList
Response.Write(objAddressEntry.Address())
Next

The ObjSession.GetAddressList method call is the line
that generates the error.

We are running Exchange 5.5. I am using CDO version
1.21. The web server and the exchange server are two
different machines. The web server, which is my localhost
for now, is running XP.

I would be thankfull for any help.

Thanks.

Jeff


Jul 21 '05 #2

Hi Peter.

I created a asp page with the test code you sent me.

When I run the code I get the folling error:

Collaboration Data Objects (0x4F7)
[Collaboration Data Objects - [MAPI_E_NOT_FOUND(8004010F)]]

The error occurs on the line:

objSession.Logon , , , false, , true, bstrProfileInfo

I have verified that the server and mailbox are valid.

I also tried the page with both Integrated and Basic security.

I guess this is telling me it can not get logged on to the server?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #3
Hi Jeff,


But I think we may focus on back to the original problem you encounter in
the first post.

I can not reproduce the problem.
I tested your code and modified as below.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim strProfileInfo As String
Dim ObjSession As New MAPI.Session
Dim objAddressListType As New MAPI.CdoAddressListTypes
Dim objAddressList As MAPI.AddressList
Dim objAddressEntry As MAPI.AddressEntry
Dim strServer As String = "" ' valid server name(here)
Dim strMailbox As String = "" ' valid mailbox here()
strProfileInfo = strServer & vbLf & strMailbox
ObjSession.Logon(, , False, True, , True, strProfileInfo)
objAddressList =
CType(ObjSession.GetAddressList(objAddressListType .CdoAddressListGAL),
MAPI.AddressList)
'list all addresses in the gal
For Each objAddressEntry In objAddressList.AddressEntries
Response.Write(objAddressEntry.Address())
Exit For
Next
End Sub
End Class

Do you have outlook? If yes, you may try to use the outlook to connect to
the exchange server with the same problem you use in the code above to see
if you can access the Global Address List?

When I run the code I get the folling error:

Collaboration Data Objects (0x4F7)
[Collaboration Data Objects - [MAPI_E_NOT_FOUND(8004010F)]] There are many possible to cause the problem, you can seach the error in
google with many result.
e.g.PRB: CDO:"MAPI_E_NOT_FOUND" Error When You Call Session.Logon
http://support.microsoft.com/?id=254567
I let you try the code just to ensure if the problem is about the IIS
authentication issue.

I look forward to hearing from you.
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------From: jeff rhoad <je********@infarmbureau.com>
References: <zy**************@cpmsftngxa06.phx.gbl>
X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
Subject: RE: Reading the Exchange GAL from asp.net page
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Message-ID: <ef**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.general
Date: Wed, 08 Oct 2003 08:24:06 -0700
NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
Lines: 1
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:111174
X-Tomcat-NG: microsoft.public.dotnet.general
Hi Peter.

I created a asp page with the test code you sent me.

When I run the code I get the folling error:

Collaboration Data Objects (0x4F7)
[Collaboration Data Objects - [MAPI_E_NOT_FOUND(8004010F)]]

The error occurs on the line:

objSession.Logon , , , false, , true, bstrProfileInfo

I have verified that the server and mailbox are valid.

I also tried the page with both Integrated and Basic security.

I guess this is telling me it can not get logged on to the server?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Jul 21 '05 #4
Hi, Jeff

With Peter's concurrence I've created an escalation with the messaging
team. You should receive a response from them by close of business on
Friday, Pacific time. If you do not, please respond here or send me an
email (remove online. from my alias) and I will expedite.

Thank you for choosing the MSDN Managed Newsgroups,

John Eikanger
Microsoft Developer Support

This posting is provided ďAS ISĒ with no warranties, and confers no rights.
"Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computerís security."
--------------------
| From: jeff rhoad <je********@infarmbureau.com>
| References: <zy**************@cpmsftngxa06.phx.gbl>
| X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
| Subject: RE: Reading the Exchange GAL from asp.net page
| Mime-Version: 1.0
| Content-Type: text/plain; charset="us-ascii"
| Content-Transfer-Encoding: 7bit
| Message-ID: <ef**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.general
| Date: Wed, 08 Oct 2003 08:24:06 -0700
| NNTP-Posting-Host: actionjackson133.dsl.frii.net 216.17.147.133
| Lines: 1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:111174
| X-Tomcat-NG: microsoft.public.dotnet.general
|
|
| Hi Peter.
|
| I created a asp page with the test code you sent me.
|
| When I run the code I get the folling error:
|
| Collaboration Data Objects (0x4F7)
| [Collaboration Data Objects - [MAPI_E_NOT_FOUND(8004010F)]]
|
| The error occurs on the line:
|
| objSession.Logon , , , false, , true, bstrProfileInfo
|
| I have verified that the server and mailbox are valid.
|
| I also tried the page with both Integrated and Basic security.
|
| I guess this is telling me it can not get logged on to the server?
|
|
|
| *** Sent via Developersdex http://www.developersdex.com ***
| Don't just participate in USENET...get rewarded for it!
|

Jul 21 '05 #5
We are trying to find the best resource on the messaging team to handle this one.

They will post a response as soon as we find a resource.

Sincerely,
Max Vaughn [MS]
Microsoft Developer Support
Disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use.

Jul 21 '05 #6


Just to bring everyone up to speed on what is going on I used the
updated code peter sent me and ran another test from my asp.net web
page. I still get the following error:

[Collaboration Data Objects - [E_FAIL(80004005)]]

after the GetAddressList method call.

Here is an updated look at my code:

Dim strProfileInfo As String
Dim ObjSession As New MAPI.Session
Dim objAddressListType As New MAPI.CdoAddressListTypes
Dim objAddressList As MAPI.AddressList

Dim objAddressEntry As MAPI.AddressEntry

Dim strServer As String = "valid exchange server"
Dim strMailbox As String = "valid alias"
strProfileInfo = strServer & vbLf & strMailbox
ObjSession.Logon(, , False, True, , True, strProfileInfo)
objAddressEntry = ObjSession.CurrentUser
Dim address = objAddressEntry.Address()
Dim name = objAddressEntry.Name()
objAddressList =
CType(ObjSession.GetAddressList(objAddressListType .CdoAddressListGAL),
MAPI.AddressList) '0 = gal

'list all addresses in the gal
For Each objAddressEntry In objAddressList.AddressEntries
Response.Write(objAddressEntry.Address())
Next
I query the name and address property of the AddressEntry object after
the logon method call and the value is "unknown" for both address and
name. I guess this means I can not get logged on to exchange but I am
pretty sure the server name and alias are valid. However, I will verify
that.

Also, I ran this code with basic security on and Integrated Security
off, and Basic Security off and Integrated security on and I got the
error both times.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #7
Jeff,

There are a couple of things that I can suggest for this problem. First
have you seen this article that outlines the usage of the CDO 1.21 library
in the

813349 Support Policy for Microsoft Exchange APIs with .NET Framework
http://support.microsoft.com/?id=813349

Also with CDO 1.21 we also encounter the following limitation even without
.Net in the picture:

247288 PRB: CDO Applications Are Not Supported in MTS or COM+
http://support.microsoft.com/?id=247288

One thing that you could try is using the ASPCOMPAT switch in your ASP
page. This make the page run in a single threaded manner:
308095 PRB: Creating STA Components in the Constructor in ASP.NET ASPCOMPAT
http://support.microsoft.com/?id=308095

So your options would be:
Try using the option above, but still be in a unsupported environment (CDO and .Net) Use CDO code in ASP and not ASP.Net
You could also use ADSI to do this, I've included some examples below for

your reference:
300121 How to Programmatically Create a GAL in Exchange 2000 Server
http://support.microsoft.com/?id=300121

241474 HOWTO: Render the Global Address List with ADSI
http://support.microsoft.com/?id=241474

I hope this helps!

- Jeff
Developer Support - Messaging
Microsoft

Jul 21 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Curt_C [MVP] | last post: by
reply views Thread by arjen1984 | last post: by
2 posts views Thread by adam.waterfield | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.