I'm currently using interop to get all local contacts out of outlook. When I first programmed the programm I used the following code:
Microsoft.Office.Interop.Outlook.Application outlookHandler = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.Items outlookItemsCollection;
MAPIFolder folderContacts = (MAPIFolder)outlookHandler.Session.GetDefaultFolder(OlDefaultFolders.olFolderContacts);
outlookItemsCollection = folderContacts.Items;
foreach (var outlookItem in outlookItemsCollection)
{
ContactItem contactItem = outlookItem as ContactItem;
//...do something
}
To get all contacts. now I've had some troubles with the emailaddress where I usedEMail1Address. I got some strange notation back from there that had not much to do with the mail address I'm looking for: "/o=Companyname/ou=City/cn=Department/cn=x.xyz" with the last part being the first part of the mail address. But when I then instead used contactItem.IMAddress I got the mail address as I had originally expected for Email1Address.
So my question is: Why is there this differnce and should IMAddress be used instead of Email1Address or am I overlooking here something?
The two addresses are completely unrelated. What you have for Email1Address is a perfectly valid EX type address (as opposed to SMTP).
When a GAL entry is added as a contact, Email1AddressType will be "EX". The SMTP address will be stored in a named MAPI property with the DASL name of http://schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/8084001F
. You can access it using ContactItem.PropertyAccessor.GetPorperty.
Take a look at that contact with OutlookSpy (select the contact and click IMessage button).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.