ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Returning Outlook email addresses (https://www.excelbanter.com/excel-programming/329251-returning-outlook-email-addresses.html)

GeorgeFD29

Returning Outlook email addresses
 
I have the following code working - talking to outlook. However, whenever I
try to return the email address of the contact, I get 'object doesn't support
this property or method' thanks for any help.

Dim OLF As Outlook.MAPIFolder
Dim olContactItem As Outlook.ContactItem
Dim ToContact As Recipient
Set OLF = GetObject("",
"Outlook.Application").GetNamespace("MAPI").GetDef aultFolder(olFolderContacts)

Set itms = OLF.Items

For i = 1 To itms.Count
Set itm = itms(i)
strContactName = itm.LastName & ", " & itm.FirstName & " " & itm.MiddleName
strEmail = itm.email
Next




Tom Ogilvy

Returning Outlook email addresses
 
change
strEmail = itm.email

to

strEmail = itm.email1address

would be my guess, but this is an excel group and an outlook group would
probably be more helpful.

--
Regards,
Tom Ogilvy

"GeorgeFD29" wrote in message
...
I have the following code working - talking to outlook. However,

whenever I
try to return the email address of the contact, I get 'object doesn't

support
this property or method' thanks for any help.

Dim OLF As Outlook.MAPIFolder
Dim olContactItem As Outlook.ContactItem
Dim ToContact As Recipient
Set OLF = GetObject("",

"Outlook.Application").GetNamespace("MAPI").GetDef aultFolder(olFolderContact
s)

Set itms = OLF.Items

For i = 1 To itms.Count
Set itm = itms(i)
strContactName = itm.LastName & ", " & itm.FirstName & " " &

itm.MiddleName
strEmail = itm.email
Next






David

Returning Outlook email addresses
 
I say your code, and tried to use it, but I'm getting a compile error on the
first line of DIM code for the MAPI folder. What am I doing wrong?

"GeorgeFD29" wrote:

I have the following code working - talking to outlook. However, whenever I
try to return the email address of the contact, I get 'object doesn't support
this property or method' thanks for any help.

Dim OLF As Outlook.MAPIFolder
Dim olContactItem As Outlook.ContactItem
Dim ToContact As Recipient
Set OLF = GetObject("",
"Outlook.Application").GetNamespace("MAPI").GetDef aultFolder(olFolderContacts)

Set itms = OLF.Items

For i = 1 To itms.Count
Set itm = itms(i)
strContactName = itm.LastName & ", " & itm.FirstName & " " & itm.MiddleName
strEmail = itm.email
Next





All times are GMT +1. The time now is 08:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com