![]() |
| 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: addressentrydetails, extract, field, individual, values |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Dear all,
I need personal details (like telephone number, internal postal code, etc.) from employees that are involved in specific tasks. What I'd like to do is: 1. find an addressEntry in Outlook 2000 (lastname, firstname as search string, filled in in a textbox on a userform), Exchange 5.5, all updates followed through. 2. extract some of the field values that are displayed in the modal form when the Details method is called Unfortunately, I've searched and experimented with several suggested solution on the internet, including CDO, but it didn't work because the AddressEntry.Fields property is not recognized. For code details see below. Does anybody have a solution how to read these field values and prevent people from typing over all the contact details of involved employees? Best regards, Mathieu NL VBA Code details Dim Temp ' Temp Variable Dim intCounter ' Counter Dim strUserName ' UserName Dim objSession ' MAPI Session Dim objInspector ' Inspector object Dim objCommandBar ' Toolbar object Dim objRecipients ' Recipients collection object Dim objRecipient ' Recipients object Dim objNewMessage ' New message object Dim objNewRecip ' New recipients collection object Dim objNewUser ' User which should be modified Dim ArrayAddresses ' Array for e-mail addresses Dim objAlias ' Aliasname object Dim objOffline ' Offline alias object Dim objNewFields ' Fields collection Dim strRetCode ' Return Code of MAPI Logon Dim objFirstName ' FirstName Dim objInitials ' Initials Dim objLastName ' LastName Dim objDisplayName ' DisplayName Dim objAddress ' Street address Dim objTitle ' Title Dim objCompany ' Company Name Dim objCity ' City Dim objDepartment ' Department Name Dim objState ' State Dim objOffice ' Office Dim objZipCode ' Zip code Dim objAssistant ' Assistant Dim objCountry ' Country Dim objBusiness1 ' Business phone and phone Dim objBusiness2 ' Business phone 2 Dim objFax ' Fax Dim objAssistant2 ' Assistant Dim objHome1 ' Home 1 Dim objHome2 ' Home 2 Dim objMobile ' Mobile Dim objPager ' Pager Dim objNotes ' Notes Dim objEMailAddresses ' E-mail addresses Dim objCollection ' Collection for Direct reports and Member of distribution lists Dim objCustomAttr1 ' Custom attribute 1 Dim objCustomAttr2 ' Custom attribute 2 Dim objCustomAttr3 ' Custom attribute 3 Dim objCustomAttr4 ' Custom attribute 4 Dim objCustomAttr5 ' Custom attribute 5 Dim objCustomAttr6 ' Custom attribute 6 Dim objCustomAttr7 ' Custom attribute 7 Dim objCustomAttr8 ' Custom attribute 8 Dim objCustomAttr9 ' Custom attribute 9 Dim objCustomAttr10 ' Custom attribute 10 Dim objCustomAttr11 ' Custom attribute 11 Dim objCustomAttr12 ' Custom attribute 12 Dim objCustomAttr13 ' Custom attribute 13 Dim objCustomAttr14 ' Custom attribute 14 Dim objCustomAttr15 ' Custom attribute 15 Set objInspector = Nothing Set objCommandBar = Nothing Set objRecipients = Nothing Set objRecipient = Nothing Set objAlias = Nothing Set objOffline = Nothing Set objFirstName = Nothing Set objInitials = Nothing Set objLastName = Nothing Set objDisplayName = Nothing Set objAddress = Nothing Set objTitle = Nothing Set objCompany = Nothing Set objCity = Nothing Set objDepartment = Nothing Set objState = Nothing Set objOffice = Nothing Set objZipCode = Nothing Set objAssistant = Nothing Set objCountry = Nothing Set objBusiness1 = Nothing Set objBusiness2 = Nothing Set objFax = Nothing Set objAssistant2 = Nothing Set objHome1 = Nothing Set objHome2 = Nothing Set objMobile = Nothing Set objPager = Nothing Set objNotes = Nothing Set objEMailAddresses = Nothing Set objCollection = Nothing Set objCustomAttr1 = Nothing Set objCustomAttr2 = Nothing Set objCustomAttr3 = Nothing Set objCustomAttr4 = Nothing Set objCustomAttr5 = Nothing Set objCustomAttr6 = Nothing Set objCustomAttr7 = Nothing Set objCustomAttr8 = Nothing Set objCustomAttr9 = Nothing Set objCustomAttr10 = Nothing Set objCustomAttr11 = Nothing Set objCustomAttr12 = Nothing Set objCustomAttr13 = Nothing Set objCustomAttr14 = Nothing Set objCustomAttr15 = Nothing Dim myOlApp As Outlook.Application Dim myNamespace As Outlook.NameSpace Dim myAddrList As Outlook.AddressList Dim myAddrEntries As Outlook.AddressEntries Dim myEntry As Outlook.AddressEntry Set myOlApp = CreateObject("Outlook.Application") Set myNamespace = myOlApp.GetNamespace("MAPI") Set myAddrList = myNamespace.AddressLists("Algemene adreslijst") 'Dutch general address list for whole company Set myAddrEntries = myAddrList.AddressEntries Set myEntry = myAddrEntries(TextBox1.Text) Set objNewFields = myEntry.Fields Set objOffline = objNewFields.Item(CdoPR_MHS_COMMON_NAME) Set objAlias = objNewFields.Item(CdoPR_ACCOUNT) Set objFirstName = objNewFields.Item(CdoPR_GIVEN_NAME) Set objInitials = objNewFields.Item(CdoPR_INITIALS) Set objLastName = objNewFields.Item(CdoPR_SURNAME) Set objDisplayName = objNewFields.Item(CdoPR_DISPLAY_NAME) Set objAddress = objNewFields.Item(CdoPR_STREET_ADDRESS) Set objTitle = objNewFields.Item(CdoPR_TITLE) Set objCompany = objNewFields.Item(CdoPR_COMPANY_NAME) Set objCity = objNewFields.Item(CdoPR_LOCALITY) Set objDepartment = objNewFields.Item(CdoPR_DEPARTMENT_NAME) Set objState = objNewFields.Item(CdoPR_STATE_OR_PROVINCE) Set objOffice = objNewFields.Item(CdoPR_OFFICE_LOCATION) Set objZipCode = objNewFields.Item(CdoPR_POSTAL_CODE) Set objAssistant = objNewFields.Item(CdoPR_ASSISTANT) Set objCountry = objNewFields.Item(CdoPR_BUSINESS_ADDRESS_COUNTRY) Set objBusiness1 = objNewFields.Item(CdoPR_BUSINESS_TELEPHONE_NUMBER) Set objBusiness2 = objNewFields.Item(CdoPR_BUSINESS2_TELEPHONE_NUMBER ) Set objFax = objNewFields.Item(CdoPR_PRIMARY_FAX_NUMBER) Set objAssistant2 = objNewFields.Item(CdoPR_ASSISTANT_TELEPHONE_NUMBER ) Set objHome1 = objNewFields.Item(CdoPR_HOME_TELEPHONE_NUMBER) Set objHome2 = objNewFields.Item(CdoPR_HOME2_TELEPHONE_NUMBER) Set objMobile = objNewFields.Item(CdoPR_MOBILE_TELEPHONE_NUMBER) Set objPager = objNewFields.Item(CdoPR_PAGER_TELEPHONE_NUMBER) Set objNotes = objNewFields.Item(CdoPR_COMMENT) Set objEMailAddresses = objNewFields.Item(PR_EMS_AB_PROXY_ADDRESSES) Set objCustomAttr1 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_1) Set objCustomAttr2 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_2) Set objCustomAttr3 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_3) Set objCustomAttr4 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_4) Set objCustomAttr5 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_5) Set objCustomAttr6 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_6) Set objCustomAttr7 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_7) Set objCustomAttr8 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_8) Set objCustomAttr9 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_9) Set objCustomAttr10 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_10 ) Set objCustomAttr11 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_11 ) Set objCustomAttr12 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_12 ) Set objCustomAttr13 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_13 ) Set objCustomAttr14 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_14 ) Set objCustomAttr15 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_15 ) On Error GoTo DialogBox MsgBox ("E-mail: " & myEntry.Address) TextBox2.Text = myEntry.UserID DialogBox: myEntry.Details |
| Ads |
|
#2
|
|||
|
|||
|
You can't use AddressEntry.Fields with an Outlook.AddressEntry object. That
is only present in a CDO AddressEntry object. You have to get the Outlook AddressEntry and then use CDO to get the equivalent CDO AddressEntry object. You would do that using the Outlook.AddressEntry.ID property to call CDO.Session.GetAddressEntry. You can't mix and match different object models. You convert from one to the other using ID or EntryID, depending on the object type. You will also need to create a CDO session object and use a piggyback logon to the existing Outlook session. BTW, CDO 1.21 client side is security restricted. You will get security prompts to allow the accesses to the CDO.AddressEntry properties. See www.cdolive.com/cdo5.htm for lots of samples on how to use CDO code. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "AB" wrote in message ... Dear all, I need personal details (like telephone number, internal postal code, etc.) from employees that are involved in specific tasks. What I'd like to do is: 1. find an addressEntry in Outlook 2000 (lastname, firstname as search string, filled in in a textbox on a userform), Exchange 5.5, all updates followed through. 2. extract some of the field values that are displayed in the modal form when the Details method is called Unfortunately, I've searched and experimented with several suggested solution on the internet, including CDO, but it didn't work because the AddressEntry.Fields property is not recognized. For code details see below. Does anybody have a solution how to read these field values and prevent people from typing over all the contact details of involved employees? Best regards, Mathieu NL VBA Code details Dim Temp ' Temp Variable Dim intCounter ' Counter Dim strUserName ' UserName Dim objSession ' MAPI Session Dim objInspector ' Inspector object Dim objCommandBar ' Toolbar object Dim objRecipients ' Recipients collection object Dim objRecipient ' Recipients object Dim objNewMessage ' New message object Dim objNewRecip ' New recipients collection object Dim objNewUser ' User which should be modified Dim ArrayAddresses ' Array for e-mail addresses Dim objAlias ' Aliasname object Dim objOffline ' Offline alias object Dim objNewFields ' Fields collection Dim strRetCode ' Return Code of MAPI Logon Dim objFirstName ' FirstName Dim objInitials ' Initials Dim objLastName ' LastName Dim objDisplayName ' DisplayName Dim objAddress ' Street address Dim objTitle ' Title Dim objCompany ' Company Name Dim objCity ' City Dim objDepartment ' Department Name Dim objState ' State Dim objOffice ' Office Dim objZipCode ' Zip code Dim objAssistant ' Assistant Dim objCountry ' Country Dim objBusiness1 ' Business phone and phone Dim objBusiness2 ' Business phone 2 Dim objFax ' Fax Dim objAssistant2 ' Assistant Dim objHome1 ' Home 1 Dim objHome2 ' Home 2 Dim objMobile ' Mobile Dim objPager ' Pager Dim objNotes ' Notes Dim objEMailAddresses ' E-mail addresses Dim objCollection ' Collection for Direct reports and Member of distribution lists Dim objCustomAttr1 ' Custom attribute 1 Dim objCustomAttr2 ' Custom attribute 2 Dim objCustomAttr3 ' Custom attribute 3 Dim objCustomAttr4 ' Custom attribute 4 Dim objCustomAttr5 ' Custom attribute 5 Dim objCustomAttr6 ' Custom attribute 6 Dim objCustomAttr7 ' Custom attribute 7 Dim objCustomAttr8 ' Custom attribute 8 Dim objCustomAttr9 ' Custom attribute 9 Dim objCustomAttr10 ' Custom attribute 10 Dim objCustomAttr11 ' Custom attribute 11 Dim objCustomAttr12 ' Custom attribute 12 Dim objCustomAttr13 ' Custom attribute 13 Dim objCustomAttr14 ' Custom attribute 14 Dim objCustomAttr15 ' Custom attribute 15 Set objInspector = Nothing Set objCommandBar = Nothing Set objRecipients = Nothing Set objRecipient = Nothing Set objAlias = Nothing Set objOffline = Nothing Set objFirstName = Nothing Set objInitials = Nothing Set objLastName = Nothing Set objDisplayName = Nothing Set objAddress = Nothing Set objTitle = Nothing Set objCompany = Nothing Set objCity = Nothing Set objDepartment = Nothing Set objState = Nothing Set objOffice = Nothing Set objZipCode = Nothing Set objAssistant = Nothing Set objCountry = Nothing Set objBusiness1 = Nothing Set objBusiness2 = Nothing Set objFax = Nothing Set objAssistant2 = Nothing Set objHome1 = Nothing Set objHome2 = Nothing Set objMobile = Nothing Set objPager = Nothing Set objNotes = Nothing Set objEMailAddresses = Nothing Set objCollection = Nothing Set objCustomAttr1 = Nothing Set objCustomAttr2 = Nothing Set objCustomAttr3 = Nothing Set objCustomAttr4 = Nothing Set objCustomAttr5 = Nothing Set objCustomAttr6 = Nothing Set objCustomAttr7 = Nothing Set objCustomAttr8 = Nothing Set objCustomAttr9 = Nothing Set objCustomAttr10 = Nothing Set objCustomAttr11 = Nothing Set objCustomAttr12 = Nothing Set objCustomAttr13 = Nothing Set objCustomAttr14 = Nothing Set objCustomAttr15 = Nothing Dim myOlApp As Outlook.Application Dim myNamespace As Outlook.NameSpace Dim myAddrList As Outlook.AddressList Dim myAddrEntries As Outlook.AddressEntries Dim myEntry As Outlook.AddressEntry Set myOlApp = CreateObject("Outlook.Application") Set myNamespace = myOlApp.GetNamespace("MAPI") Set myAddrList = myNamespace.AddressLists("Algemene adreslijst") 'Dutch general address list for whole company Set myAddrEntries = myAddrList.AddressEntries Set myEntry = myAddrEntries(TextBox1.Text) Set objNewFields = myEntry.Fields Set objOffline = objNewFields.Item(CdoPR_MHS_COMMON_NAME) Set objAlias = objNewFields.Item(CdoPR_ACCOUNT) Set objFirstName = objNewFields.Item(CdoPR_GIVEN_NAME) Set objInitials = objNewFields.Item(CdoPR_INITIALS) Set objLastName = objNewFields.Item(CdoPR_SURNAME) Set objDisplayName = objNewFields.Item(CdoPR_DISPLAY_NAME) Set objAddress = objNewFields.Item(CdoPR_STREET_ADDRESS) Set objTitle = objNewFields.Item(CdoPR_TITLE) Set objCompany = objNewFields.Item(CdoPR_COMPANY_NAME) Set objCity = objNewFields.Item(CdoPR_LOCALITY) Set objDepartment = objNewFields.Item(CdoPR_DEPARTMENT_NAME) Set objState = objNewFields.Item(CdoPR_STATE_OR_PROVINCE) Set objOffice = objNewFields.Item(CdoPR_OFFICE_LOCATION) Set objZipCode = objNewFields.Item(CdoPR_POSTAL_CODE) Set objAssistant = objNewFields.Item(CdoPR_ASSISTANT) Set objCountry = objNewFields.Item(CdoPR_BUSINESS_ADDRESS_COUNTRY) Set objBusiness1 = objNewFields.Item(CdoPR_BUSINESS_TELEPHONE_NUMBER) Set objBusiness2 = objNewFields.Item(CdoPR_BUSINESS2_TELEPHONE_NUMBER ) Set objFax = objNewFields.Item(CdoPR_PRIMARY_FAX_NUMBER) Set objAssistant2 = objNewFields.Item(CdoPR_ASSISTANT_TELEPHONE_NUMBER ) Set objHome1 = objNewFields.Item(CdoPR_HOME_TELEPHONE_NUMBER) Set objHome2 = objNewFields.Item(CdoPR_HOME2_TELEPHONE_NUMBER) Set objMobile = objNewFields.Item(CdoPR_MOBILE_TELEPHONE_NUMBER) Set objPager = objNewFields.Item(CdoPR_PAGER_TELEPHONE_NUMBER) Set objNotes = objNewFields.Item(CdoPR_COMMENT) Set objEMailAddresses = objNewFields.Item(PR_EMS_AB_PROXY_ADDRESSES) Set objCustomAttr1 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_1) Set objCustomAttr2 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_2) Set objCustomAttr3 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_3) Set objCustomAttr4 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_4) Set objCustomAttr5 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_5) Set objCustomAttr6 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_6) Set objCustomAttr7 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_7) Set objCustomAttr8 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_8) Set objCustomAttr9 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_9) Set objCustomAttr10 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_10 ) Set objCustomAttr11 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_11 ) Set objCustomAttr12 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_12 ) Set objCustomAttr13 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_13 ) Set objCustomAttr14 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_14 ) Set objCustomAttr15 = objNewFields.Item(PR_EMS_AB_EXTENSION_ATTRIBUTE_15 ) On Error GoTo DialogBox MsgBox ("E-mail: " & myEntry.Address) TextBox2.Text = myEntry.UserID DialogBox: myEntry.Details |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Extract individual appointments from RecurrencePattern ? | Simon Shutter | Outlook and VBA | 1 | July 7th 06 11:04 PM |
| Removing Certain Field Values In Contacts | Nathan Sokalski | Outlook - General Queries | 7 | April 4th 06 06:04 PM |
| Field values that disappear in OL 2003 | Fred Russell | Outlook - Using Forms | 6 | March 7th 06 11:55 PM |
| How do I find the "Children" field in Details tab in Outlook Conta | Widget | Outlook - Using Contacts | 1 | January 12th 06 09:53 PM |
| getting the AddressEntry object to update for a Personal Address Book | peteshaw | Outlook - Using Contacts | 0 | January 10th 06 01:31 PM |