Outlook Add-in

J

jayadev

Can anyone tell me to access the homephonenumber of the
personal address book recipient using CDO,

Dim objSession As MAPI.Session
Set objSession = CreateObject("MAPI.Session")
objSession.Logon "", "", False, False, 0
Dim objMessage As MAPI.Message
Dim oAddressEntries As AddressEntries
Dim oAddressList As AddressList
Dim oRecipients As Recipients
Dim oRecipient As Recipient
Dim oAddressEntry As AddressEntry
Dim oMember As AddressEntry
Dim MyFields As MAPI.Fields
Dim myField As MAPI.Field

Set objMessage = objSession.Outbox.Messages.Add
Set oRecipient = objMessage.Recipients.Add

oRecipient.Name = "(e-mail address removed)"
oRecipient.Resolve
Set oAddressEntry = oRecipient.AddressEntry
Set MyFields = oAddressEntry.Fields
For Each myField In MyFields
MsgBox myField.Value
Next
Set Mydept = MyFields
(CdoPR_OFFICE_TELEPHONE_NUMBER).Value


It is genearating an error even though a number exists


Can anyone please help me out.
 
K

Ken Slovak - [MVP - Outlook]

That's the tag for business number, not personal. See
www.cdolive.com/cdo10.htm for a list of CDO property tags.

Set Mydept = MyFields _
(CdoPR_OFFICE_TELEPHONE_NUMBER).Value

The result is a string, you are using Set which is only for objects.
Also, Mydept is not declared. Assuming it's a string variable does
this work?
Mydept = MyFields _
(CdoPR_OFFICE_TELEPHONE_NUMBER).Value

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Redemption question 1
Emailing Document with Macros 2
Using CDO with Outlook 0
CDO - How? 2
[outlook] distribution list 0
GAL program acces in outlook 2007 2
Add Attachment 2
Run time error 2

Top