L
laperled
Hi guys,
i'm using C# with CDO 1.21 (Exchange dll) and ADODB for listing all
the Personal Contacts of my users and sending that into a database!
I'm using this code for that :
iPerson = new CDO.PersonClass();
iPerson.DataSource.Open(strEmailAddress2, null,
ADODB.ConnectModeEnum.adModeRead,
ADODB.RecordCreateOptionsEnum.adFailIfNotExists,
ADODB.RecordOpenOptionsEnum.adOpenSource, String.Empty, String.Empty);
iMailbox =
(CDO.IMailbox)iPerson.GetInterface("IMailbox");
Console.WriteLine(iMailbox.BaseFolder);
ADODB.Connection oCn = new ADODB.Connection();
ADODB.Recordset oRs = new ADODB.Recordset();
ADODB.Fields oFields;
oCn.Provider = "ExOLEDB.Datasource";
oCn.Open(iMailbox.Contacts, "", "", -1);
string strSql;
strSql = "";
strSql = "select ";
strSql = strSql + "\"DAV:href\",
\"urn:schemas:contacts:cn\" ";
strSql = strSql + ", \"http://
schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/
0x8083\" ";
strSql = strSql + ",
\"urn:schemas:contacts:businesshomepage\" ";
strSql = strSql + ",
\"urn:schemas:contacts:callbackphone\" ";
strSql = strSql + ", \"urn:schemas:contacts:co
\" ";
strSql = strSql + ",
\"urn:schemas:contacts:facsimiletelephonenumber\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homeCity\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homeCountry\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homefax\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homephone2\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homePhone\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homePostaladdress\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homePostalCode\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homepostofficebox\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homeState\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homeStreet\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mailingcity\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mailingcountry\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mailingpostaladdress\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mailingpostalcode\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mailingpostofficebox\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mailingstate\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mailingstreet\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mobile\" ";
strSql = strSql + ",
\"urn:schemas:contactsffice2telephonenumber\" ";
strSql = strSql + ",
\"urn:schemas:contactsfficetelephonenumber\" ";
strSql = strSql + ",
\"urn:schemas:contactsrganizationmainphone\" ";
strSql = strSql + ",
\"urn:schemas:contactsthercity\" ";
strSql = strSql + ",
\"urn:schemas:contactsthercountry\" ";
strSql = strSql + ",
\"urn:schemas:contactstherfax\" ";
strSql = strSql + ",
\"urn:schemas:contactsthermobile\" ";
strSql = strSql + ",
\"urn:schemas:contactstherpager\" ";
strSql = strSql + ",
\"urn:schemas:contactstherpostaladdress\" ";
strSql = strSql + ",
\"urn:schemas:contactstherpostalcode\" ";
strSql = strSql + ",
\"urn:schemas:contactstherpostofficebox\" ";
strSql = strSql + ",
\"urn:schemas:contactstherstate\" ";
strSql = strSql + ",
\"urn:schemas:contactstherstreet\" ";
strSql = strSql + ",
\"urn:schemas:contactstherTelephone\" ";
strSql = strSql + ",
\"urn:schemas:contactsager\" ";
strSql = strSql + ",
\"urn:schemas:contactsostalcode\" ";
strSql = strSql + ",
\"urn:schemas:contactsostofficebox\" ";
strSql = strSql + ",
\"urn:schemas:contactsrofession\" ";
strSql = strSql + ",
\"urn:schemas:contacts:street\" ";
strSql = strSql + ",
\"urn:schemas:contacts:telephoneNumber\" ";
strSql = strSql + ",
\"urn:schemas:contacts:telephonenumber2\" ";
strSql = strSql + ",
\"urn:schemas:contacts:telexnumber\" ";
strSql = strSql + ",
\"urn:schemas:contacts:title\" ";
strSql = strSql + ",
\"urn:schemas:contacts:workaddress\" ";
strSql = strSql + " from scope ('shallow
traversal of " + "\"";
strSql = strSql + iMailbox.Contacts + "\"') ";
oRs.Open(strSql,
oCn, ADODB.CursorTypeEnum.adOpenUnspecified,
ADODB.LockTypeEnum.adLockOptimistic, 1);
This is only a part of the code, but it show you how i do that! The
problem, is that i want the Unique Identifier of that contact!
Is there a way for me to retrieve a unique identifier of the contact?
Thanks a zillion!
i'm using C# with CDO 1.21 (Exchange dll) and ADODB for listing all
the Personal Contacts of my users and sending that into a database!
I'm using this code for that :
iPerson = new CDO.PersonClass();
iPerson.DataSource.Open(strEmailAddress2, null,
ADODB.ConnectModeEnum.adModeRead,
ADODB.RecordCreateOptionsEnum.adFailIfNotExists,
ADODB.RecordOpenOptionsEnum.adOpenSource, String.Empty, String.Empty);
iMailbox =
(CDO.IMailbox)iPerson.GetInterface("IMailbox");
Console.WriteLine(iMailbox.BaseFolder);
ADODB.Connection oCn = new ADODB.Connection();
ADODB.Recordset oRs = new ADODB.Recordset();
ADODB.Fields oFields;
oCn.Provider = "ExOLEDB.Datasource";
oCn.Open(iMailbox.Contacts, "", "", -1);
string strSql;
strSql = "";
strSql = "select ";
strSql = strSql + "\"DAV:href\",
\"urn:schemas:contacts:cn\" ";
strSql = strSql + ", \"http://
schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/
0x8083\" ";
strSql = strSql + ",
\"urn:schemas:contacts:businesshomepage\" ";
strSql = strSql + ",
\"urn:schemas:contacts:callbackphone\" ";
strSql = strSql + ", \"urn:schemas:contacts:co
\" ";
strSql = strSql + ",
\"urn:schemas:contacts:facsimiletelephonenumber\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homeCity\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homeCountry\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homefax\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homephone2\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homePhone\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homePostaladdress\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homePostalCode\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homepostofficebox\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homeState\" ";
strSql = strSql + ",
\"urn:schemas:contacts:homeStreet\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mailingcity\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mailingcountry\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mailingpostaladdress\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mailingpostalcode\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mailingpostofficebox\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mailingstate\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mailingstreet\" ";
strSql = strSql + ",
\"urn:schemas:contacts:mobile\" ";
strSql = strSql + ",
\"urn:schemas:contactsffice2telephonenumber\" ";
strSql = strSql + ",
\"urn:schemas:contactsfficetelephonenumber\" ";
strSql = strSql + ",
\"urn:schemas:contactsrganizationmainphone\" ";
strSql = strSql + ",
\"urn:schemas:contactsthercity\" ";
strSql = strSql + ",
\"urn:schemas:contactsthercountry\" ";
strSql = strSql + ",
\"urn:schemas:contactstherfax\" ";
strSql = strSql + ",
\"urn:schemas:contactsthermobile\" ";
strSql = strSql + ",
\"urn:schemas:contactstherpager\" ";
strSql = strSql + ",
\"urn:schemas:contactstherpostaladdress\" ";
strSql = strSql + ",
\"urn:schemas:contactstherpostalcode\" ";
strSql = strSql + ",
\"urn:schemas:contactstherpostofficebox\" ";
strSql = strSql + ",
\"urn:schemas:contactstherstate\" ";
strSql = strSql + ",
\"urn:schemas:contactstherstreet\" ";
strSql = strSql + ",
\"urn:schemas:contactstherTelephone\" ";
strSql = strSql + ",
\"urn:schemas:contactsager\" ";
strSql = strSql + ",
\"urn:schemas:contactsostalcode\" ";
strSql = strSql + ",
\"urn:schemas:contactsostofficebox\" ";
strSql = strSql + ",
\"urn:schemas:contactsrofession\" ";
strSql = strSql + ",
\"urn:schemas:contacts:street\" ";
strSql = strSql + ",
\"urn:schemas:contacts:telephoneNumber\" ";
strSql = strSql + ",
\"urn:schemas:contacts:telephonenumber2\" ";
strSql = strSql + ",
\"urn:schemas:contacts:telexnumber\" ";
strSql = strSql + ",
\"urn:schemas:contacts:title\" ";
strSql = strSql + ",
\"urn:schemas:contacts:workaddress\" ";
strSql = strSql + " from scope ('shallow
traversal of " + "\"";
strSql = strSql + iMailbox.Contacts + "\"') ";
oRs.Open(strSql,
oCn, ADODB.CursorTypeEnum.adOpenUnspecified,
ADODB.LockTypeEnum.adLockOptimistic, 1);
This is only a part of the code, but it show you how i do that! The
problem, is that i want the Unique Identifier of that contact!
Is there a way for me to retrieve a unique identifier of the contact?
Thanks a zillion!