By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,735 Members | 1,445 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,735 IT Pros & Developers. It's quick & easy.

Getting Global Contacts from Exchange

P: n/a

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 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

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 17 '05 #2

P: n/a

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 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.