473,395 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Getting Global Contacts from Exchange


Environment
C#, Asp.Net 2.0, Windows 2000 Server
Problem
I'm trying to enumerate all the names in the global contacts on the exchange
server using CDO / ADO / (whatever I can).
In writing an ASP.Net support ticket application, I want to populate the
list of "Who reported this ticket" with names from the global contacts.
An extension of this would then be to allow the user to add a person to the
global contact via the web page, should they not exist in the contacts list.

To start with, I'm writing a basic windows application with one textbox as
the input providing the URL to get the contacts from, and one text box as
the output to put any contacts names I find into. I compile this application
then try to run it on the exchange server, but get an error saying the
"Bookmark is invalid" the first (and every time) MoveNext is called on the
result record set.

I've looked into this error and some articles on the web relate it to
exchange, recommending a machine restart. I've done that the problem
persists. There's no errors with this exchange server with Outlook for
example, so I'm hard pressed to think it's not something with my
application.

Any help or guidance would be appreciated, and yes, I've seen the articles
google gives you on "enumerating contacts with c#" (terrible IMO), and have
read the microsoft articles.
Code
string url = urlTextBox.Text;

ADODB.Connection con = null;
ADODB.Recordset rs = null;

try
{
// create the connection
con = new ADODB.Connection();
con.Provider = "exoledb.datasource";
con.Open(url, "", "", 0);

// build SQL query
string SqlQuery = "SELECT * FROM \"" + url + "\"";

// build the record set object
rs = new ADODB.Recordset();
rs.Open(SqlQuery,
con,
ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockOptimistic,
0);

// enumarate through the retrieved record set
for (; !rs.EOF; rs.MoveNext()) // <<<--- "Bookmark is invalid"
exception
{
usernamesTextBox.Text +=
rs.Fields["urn:schemas:contacts:givenName"].Value.ToString() +"\r\n";
}

}
catch (Exception ex)
{
MessageBox.Show("OOPS!\r\n------\r\n\r\n" + ex.ToString());
}
finally
{

if (rs != null && rs.State ==
(int)ADODB.ObjectStateEnum.adStateOpen)
rs.Close();
if (con != null && con.State ==
(int)ADODB.ObjectStateEnum.adStateOpen)
con.Close();
}
Nov 19 '05 #1
1 1036

MDAC 2.6 appears to have this problem, upgrading the server to 2.8 sorted it
out.

"Dan Bass" <Not Listed> wrote in message
news:ez*************@TK2MSFTNGP09.phx.gbl...

Environment
C#, Asp.Net 2.0, Windows 2000 Server
Problem
I'm trying to enumerate all the names in the global contacts on the
exchange server using CDO / ADO / (whatever I can).
In writing an ASP.Net support ticket application, I want to populate the
list of "Who reported this ticket" with names from the global contacts.
An extension of this would then be to allow the user to add a person to
the global contact via the web page, should they not exist in the contacts
list.

To start with, I'm writing a basic windows application with one textbox as
the input providing the URL to get the contacts from, and one text box as
the output to put any contacts names I find into. I compile this
application then try to run it on the exchange server, but get an error
saying the "Bookmark is invalid" the first (and every time) MoveNext is
called on the result record set.

I've looked into this error and some articles on the web relate it to
exchange, recommending a machine restart. I've done that the problem
persists. There's no errors with this exchange server with Outlook for
example, so I'm hard pressed to think it's not something with my
application.

Any help or guidance would be appreciated, and yes, I've seen the articles
google gives you on "enumerating contacts with c#" (terrible IMO), and
have read the microsoft articles.
Code
string url = urlTextBox.Text;

ADODB.Connection con = null;
ADODB.Recordset rs = null;

try
{
// create the connection
con = new ADODB.Connection();
con.Provider = "exoledb.datasource";
con.Open(url, "", "", 0);

// build SQL query
string SqlQuery = "SELECT * FROM \"" + url + "\"";

// build the record set object
rs = new ADODB.Recordset();
rs.Open(SqlQuery,
con,
ADODB.CursorTypeEnum.adOpenDynamic,
ADODB.LockTypeEnum.adLockOptimistic,
0);

// enumarate through the retrieved record set
for (; !rs.EOF; rs.MoveNext()) // <<<--- "Bookmark is invalid"
exception
{
usernamesTextBox.Text +=
rs.Fields["urn:schemas:contacts:givenName"].Value.ToString() +"\r\n";
}

}
catch (Exception ex)
{
MessageBox.Show("OOPS!\r\n------\r\n\r\n" + ex.ToString());
}
finally
{

if (rs != null && rs.State ==
(int)ADODB.ObjectStateEnum.adStateOpen)
rs.Close();
if (con != null && con.State ==
(int)ADODB.ObjectStateEnum.adStateOpen)
con.Close();
}

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: John | last post by:
I have a linked table in Access to an Exhange Server Contacts Folder. The problem I am having is that only the Contacts that have a valid email (SMTP, EX or FAX) show up in the table. Is there a...
2
by: Dan Bass | last post by:
Environment C#, Asp.Net 2.0, Windows 2000 Server Problem I'm trying to enumerate all the names in the global contacts on the exchange server using CDO / ADO / (whatever I can). In writing an...
0
by: George Durzi | last post by:
Hey all, I finally found the necessary resources in the Exchange 2003 SDK to "pull" Contacts out of Exchange and display them on a WebForm. I have been trying to do this forever, and couldn't...
1
by: SWu | last post by:
Hello everyone, I am working on an Internet website for an Application Service Provider. A user can store employee details on the site. I am now researching the feasibility of accessing the...
11
by: ML | last post by:
What is th best/easiest way to access a public contacts folder on an Exchange server from a winforms vb.net applciation? I would like to be able to provide the user with a list of contacts and...
1
by: tyronne | last post by:
I have created a data base that is linked to contacts in personA's outlook contacts, I need personB and PersonC to be able to also edit the data base which include a dropdown for personA's...
2
by: tthomas | last post by:
Greetings, I am using CDO.Message to send email messages from my application. I now need to send email to existing distribution lists in our Global Address List. However, our exchange server...
0
by: eric.nguyen312 | last post by:
Hi, I want to know if its possible to export my Contacts table to Global Address List on Exchange so I can view all the contacts in Outlook? Thanks, Eric
0
by: BD | last post by:
I am developing a SQL Server application and I would like to populate a list box with the names in our public contacts that are on Exchange Server. How can I accomplish this without a 3rd party...
2
by: =?Utf-8?B?VmlkZHM=?= | last post by:
Hi All, Could anyone please help me regarding this issue.I need to access or Import Outlook Contact Details from my Asp.Net web application my code behind is c#. Thanks in advance. Regards,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.