![]() |
| If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|||||||
| Tags: address, contact, email, exchange, shares, smtp, user |
|
|
|
Thread Tools | Display Modes |
|
#11
|
|||
|
|||
|
Here's the working code for future reference:
Outlook._Application olApp = new Outlook.ApplicationClass(); Outlook._NameSpace olNS = olApp.GetNamespace("MAPI"); Outlook.MAPIFolder oFolder = olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderContacts); ContactItem contact = olNS.GetDefaultFolder(OlDefaultFolders.olFolderCon tacts).Items[1] as ContactItem; MAPIUtils mapiUtils = new MAPIUtils(); int result = mapiUtils.GetIDsFromNames( contact.MAPIOBJECT, "{00062004-0000-0000-C000-000000000046}", 0x8085, false); object value = mapiUtils.HrGetOneProp(contact.MAPIOBJECT, result); string entryID = mapiUtils.HrArrayToString(value); Redemption.AddressEntry addressEntry = mapiUtils.GetAddressEntryFromID(entryID); const int g_PR_SMTP_ADDRESS_W = unchecked((int)0x39FE001E); string smtpEmailAddress = mapiUtils.HrGetOneProp(addressEntry.MAPIOBJECT, g_PR_SMTP_ADDRESS_W) as string; |
| Ads |
|
#12
|
|||
|
|||
|
Keep in mind that PR_SMTP_ADDRESS is only available in the online mode. In
the cached mode (which is used by default), you need to use PR_EMS_AB_PROXY_ADDRESSES property. Since you are using Redemption, why not use RDOContact.Email1EntryID along with RDOSession.GetAddressEntryFromID as I suggested in my previous reply? Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "Jeff" wrote in message oups.com... Here's the working code for future reference: Outlook._Application olApp = new Outlook.ApplicationClass(); Outlook._NameSpace olNS = olApp.GetNamespace("MAPI"); Outlook.MAPIFolder oFolder = olNS.GetDefaultFolder(Outlook.OlDefaultFolders.olF olderContacts); ContactItem contact = olNS.GetDefaultFolder(OlDefaultFolders.olFolderCon tacts).Items[1] as ContactItem; MAPIUtils mapiUtils = new MAPIUtils(); int result = mapiUtils.GetIDsFromNames( contact.MAPIOBJECT, "{00062004-0000-0000-C000-000000000046}", 0x8085, false); object value = mapiUtils.HrGetOneProp(contact.MAPIOBJECT, result); string entryID = mapiUtils.HrArrayToString(value); Redemption.AddressEntry addressEntry = mapiUtils.GetAddressEntryFromID(entryID); const int g_PR_SMTP_ADDRESS_W = unchecked((int)0x39FE001E); string smtpEmailAddress = mapiUtils.HrGetOneProp(addressEntry.MAPIOBJECT, g_PR_SMTP_ADDRESS_W) as string; |
|
#13
|
|||
|
|||
|
Hi All,
For what it's worth getting contact info in SMTP format for me was tough. Turns out half of my contacts are coded as SMTP when they're really exchange (EX or X500) type. Anyhow, this thread was very useful, so to give back some...please find below my Visual Basic Scripting (VBS) code to extract SMTP address from the contact book, evaluate them (to see if they are really SMTP or exchange), contact the Exchange to get the SMTP value if they are exchange, and dump it all to an Excel spreadsheet. Thanks to Dmitri for that awesome Redemption work, without which this would have been dare I say inprobable!!! Regards! '************************************** '************************************** '************************************** Dim myItem Dim myContacts Dim myContact Dim addressEntry Dim RDOSession Dim RDOAddressEntry Dim Recipient Dim objXL Dim myOlApp Dim utils Dim myNamespace Dim value Set objXL = WScript.CreateObject("Excel.Application") set utils = CreateObject("Redemption.MAPIUtils") Set myOlApp = CreateObject("Outlook.Application") Set myNamespace = myOlApp.GetNamespace("MAPI") set RDOSession = CreateObject("Redemption.RDOSession") RDOSession.MAPIOBJECT=myOlApp.Session.MAPIOBJECT Set myContacts = RDOSession.GetDefaultFolder(10).Items objXL.Visible = TRUE objXL.WorkBooks.Add objXL.Columns(1).ColumnWidth = 40 objXL.Columns(2).ColumnWidth = 40 objXL.Columns(3).ColumnWidth = 40 objXL.Cells(1, 1).Value = "Name" objXL.Cells(1, 1).Font.Bold = TRUE objXL.Cells(1, 2).Value = "Nickname" objXL.Cells(1, 2).Font.Bold = TRUE objXL.Cells(1, 3).Value = "Email Address" objXL.Cells(1, 3).Font.Bold = TRUE Dacount = 1 For each myContact in myContacts if TypeName(myContact)= "RDOContactItem" Then result = utils.GetIDsFromNames(myContact.MAPIOBJECT,"{00062 004-0000-0000-C000-000000000046}",&H8085,false) value = utils.HrGetOneProp(myContact.MAPIOBJECT, result) if not isempty(value) then Dacount = Dacount + 1 entryID = utils.HrArrayToString(value) set RDOAddressEntry = RDOSession.GetAddressEntryFromID( entryID) smtpEmailAddress= RDOAddressEntry.SmtpAddress objXL.Cells(Dacount, 1).value = myContact.FirstName+" "+myContact.LastName objXL.Cells(Dacount, 2).value = myContact.NickName if mid(smtpEmailAddress,1,2) = "/o" then foundSMTP = InStr(1,smtpEmailAddress,"SMTP:") if foundSMTP 0 then smtpEmailAddress=mid(smtpEmailAddress,foundSMTP+5) objXL.Cells(Dacount, 3).value = smtpEmailAddress else foundSMTP = InStr(1,smtpEmailAddress,"Recipients/cn=") smtpEmailAddress=mid(smtpEmailAddress,foundSMTP+14 ) set Recipient = utils.CreateRecipient(smtpEmailAddress, 0,0) if Recipient.Resolved then objXL.Cells(Dacount, 3).value = Recipient.AddressEntry.SMTPAddress else smtpEmailAddress = "***Not avialable***" objXL.Cells(Dacount, 3).value = smtpEmailAddress objXL.Cells(Dacount, 3).Font.Bold = TRUE end if end if else if smtpEmailAddress = "" then smtpEmailAddress = "***Not avialable***" objXL.Cells(Dacount, 3).value = smtpEmailAddress objXL.Cells(Dacount, 3).Font.Bold = TRUE end if objXL.Cells(Dacount, 3).value = smtpEmailAddress end if end if end if next msgbox "Contact extraction done!",,"Contact extractor" |
|
#14
|
|||
|
|||
|
A couple of fcomments:
1. There is not reason to use MAPIUtils - RDOContactItem (derived from RDOMail, derived in turn from MAPIProp), exposes the GetIDsFromNames. Or you can simply pass the property tag as a DASL name when accessing the property through Fields. More than that, you can simply read the RDOContactItem.Email1Address and RDOContactItem.Email1EntryID properties. 2. There is no reason to parse anything - RDOAddressEntry.SmtpAddress is guaranteed to return a valid SMTP address or an empty string. Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "John" wrote in message ... Hi All, For what it's worth getting contact info in SMTP format for me was tough. Turns out half of my contacts are coded as SMTP when they're really exchange (EX or X500) type. Anyhow, this thread was very useful, so to give back some...please find below my Visual Basic Scripting (VBS) code to extract SMTP address from the contact book, evaluate them (to see if they are really SMTP or exchange), contact the Exchange to get the SMTP value if they are exchange, and dump it all to an Excel spreadsheet. Thanks to Dmitri for that awesome Redemption work, without which this would have been dare I say inprobable!!! Regards! '************************************** '************************************** '************************************** Dim myItem Dim myContacts Dim myContact Dim addressEntry Dim RDOSession Dim RDOAddressEntry Dim Recipient Dim objXL Dim myOlApp Dim utils Dim myNamespace Dim value Set objXL = WScript.CreateObject("Excel.Application") set utils = CreateObject("Redemption.MAPIUtils") Set myOlApp = CreateObject("Outlook.Application") Set myNamespace = myOlApp.GetNamespace("MAPI") set RDOSession = CreateObject("Redemption.RDOSession") RDOSession.MAPIOBJECT=myOlApp.Session.MAPIOBJECT Set myContacts = RDOSession.GetDefaultFolder(10).Items objXL.Visible = TRUE objXL.WorkBooks.Add objXL.Columns(1).ColumnWidth = 40 objXL.Columns(2).ColumnWidth = 40 objXL.Columns(3).ColumnWidth = 40 objXL.Cells(1, 1).Value = "Name" objXL.Cells(1, 1).Font.Bold = TRUE objXL.Cells(1, 2).Value = "Nickname" objXL.Cells(1, 2).Font.Bold = TRUE objXL.Cells(1, 3).Value = "Email Address" objXL.Cells(1, 3).Font.Bold = TRUE Dacount = 1 For each myContact in myContacts if TypeName(myContact)= "RDOContactItem" Then result = utils.GetIDsFromNames(myContact.MAPIOBJECT,"{00062 004-0000-0000-C000-000000000046}",&H8085,false) value = utils.HrGetOneProp(myContact.MAPIOBJECT, result) if not isempty(value) then Dacount = Dacount + 1 entryID = utils.HrArrayToString(value) set RDOAddressEntry = RDOSession.GetAddressEntryFromID( entryID) smtpEmailAddress= RDOAddressEntry.SmtpAddress objXL.Cells(Dacount, 1).value = myContact.FirstName+" "+myContact.LastName objXL.Cells(Dacount, 2).value = myContact.NickName if mid(smtpEmailAddress,1,2) = "/o" then foundSMTP = InStr(1,smtpEmailAddress,"SMTP:") if foundSMTP 0 then smtpEmailAddress=mid(smtpEmailAddress,foundSMTP+5) objXL.Cells(Dacount, 3).value = smtpEmailAddress else foundSMTP = InStr(1,smtpEmailAddress,"Recipients/cn=") smtpEmailAddress=mid(smtpEmailAddress,foundSMTP+14 ) set Recipient = utils.CreateRecipient(smtpEmailAddress, 0,0) if Recipient.Resolved then objXL.Cells(Dacount, 3).value = Recipient.AddressEntry.SMTPAddress else smtpEmailAddress = "***Not avialable***" objXL.Cells(Dacount, 3).value = smtpEmailAddress objXL.Cells(Dacount, 3).Font.Bold = TRUE end if end if else if smtpEmailAddress = "" then smtpEmailAddress = "***Not avialable***" objXL.Cells(Dacount, 3).value = smtpEmailAddress objXL.Cells(Dacount, 3).Font.Bold = TRUE end if objXL.Cells(Dacount, 3).value = smtpEmailAddress end if end if end if next msgbox "Contact extraction done!",,"Contact extractor" |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Redemption and hiding user in exchange from address lists | aniallator1@gmail.com | Outlook and VBA | 8 | August 7th 06 07:53 PM |
| SMTP Rejected email address | FyrFtrEmt | Outlook Express | 4 | June 19th 06 12:10 AM |
| How to determine what SMTP address email was sent to? | BCole8888 | Outlook - General Queries | 3 | February 8th 06 04:08 PM |
| Why do all of my contact email address have SMTP at the end? | Al S. | Outlook - Using Contacts | 1 | February 7th 06 04:32 PM |
| Set which local email account can send mail to contacts in address book. (associating an email address with a contact) | Scott Streit | Outlook - General Queries | 3 | January 27th 06 03:57 PM |