Automate opening outlook and finding contact

G

Guest

hello, i have an access database that finds an outlook contact alias. (ex.
ABCDE) Is there any way i can have access search the contacts and return the
contact full name? I don't know if there is a way to open outlook, open
address book, search by alias and return contact full name. So for
example, the database returns ABCJD - opens outlook, opens address book,
searches for alias ABCJD and returns full name John Doe.

Is it possible?
 
D

David C. Holley

YES. This should get you started, however there isn't an ALIAS property
for ContactItems listed in the Outlook Object Model/Outlook Help. Which
property where you referring to? (The code below only looks in the
default Contact folder. I'm checking on how to loop through all folders.)

Sub snoopContacts(strContact As String)

Dim objOutlook As Outlook.Application
Dim nms As Outlook.NameSpace
Dim targetFolder As Outlook.MAPIFolder
Dim targetItems As Outlook.Items
Dim targetContact As Outlook.ContactItem
Dim strFilter As String

Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
Set targetFolder = nms.GetDefaultFolder(olFolderContacts)

'The [] around the property are required
'Not all ContactItems will have a FullName and example would be
'if you have a Company listed in your contacts where the company
'name is listed in the COMPANY field, but no FIRST/LAST Name is
'provided
strFilter = "[FullName]=" & Chr(34) & strContact & Chr(34)
Set targetItems = targetFolder.Items.Restrict(strFilter)

Debug.Print targetItems.Count

Stop

Set targetItems = Nothing
Set targetFolder = Nothing
Set nms = Nothing
Set objOutlook = Nothing

End Sub
 
G

Guest

Thanks for the response. Sorry about the lateness, i've been away.
2 things i need to add. First, the string being searched for is being found
by a query in a calculated field. It is not stored anywhere. I'm not sure if
the code below reflects that. How would you pass the value from the access
query to the code?

Second, i'm guessing the alias field is called the "NickName" field in the
outlook object model. That's the closest thing i could find to alias.
Any more help would be greatly appreciated.

Thanks

David C. Holley said:
YES. This should get you started, however there isn't an ALIAS property
for ContactItems listed in the Outlook Object Model/Outlook Help. Which
property where you referring to? (The code below only looks in the
default Contact folder. I'm checking on how to loop through all folders.)

Sub snoopContacts(strContact As String)

Dim objOutlook As Outlook.Application
Dim nms As Outlook.NameSpace
Dim targetFolder As Outlook.MAPIFolder
Dim targetItems As Outlook.Items
Dim targetContact As Outlook.ContactItem
Dim strFilter As String

Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
Set targetFolder = nms.GetDefaultFolder(olFolderContacts)

'The [] around the property are required
'Not all ContactItems will have a FullName and example would be
'if you have a Company listed in your contacts where the company
'name is listed in the COMPANY field, but no FIRST/LAST Name is
'provided
strFilter = "[FullName]=" & Chr(34) & strContact & Chr(34)
Set targetItems = targetFolder.Items.Restrict(strFilter)

Debug.Print targetItems.Count

Stop

Set targetItems = Nothing
Set targetFolder = Nothing
Set nms = Nothing
Set objOutlook = Nothing

End Sub
hello, i have an access database that finds an outlook contact alias. (ex.
ABCDE) Is there any way i can have access search the contacts and return the
contact full name? I don't know if there is a way to open outlook, open
address book, search by alias and return contact full name. So for
example, the database returns ABCJD - opens outlook, opens address book,
searches for alias ABCJD and returns full name John Doe.

Is it possible?
 
D

David C. Holley

First, you need to confirm for certain that "NickName" is the field to
search. Doesn't help to search your daughter's dresser for your son't
baseball bat.


Thanks for the response. Sorry about the lateness, i've been away.
2 things i need to add. First, the string being searched for is being found
by a query in a calculated field. It is not stored anywhere. I'm not sure if
the code below reflects that. How would you pass the value from the access
query to the code?

Second, i'm guessing the alias field is called the "NickName" field in the
outlook object model. That's the closest thing i could find to alias.
Any more help would be greatly appreciated.

Thanks

:

YES. This should get you started, however there isn't an ALIAS property
for ContactItems listed in the Outlook Object Model/Outlook Help. Which
property where you referring to? (The code below only looks in the
default Contact folder. I'm checking on how to loop through all folders.)

Sub snoopContacts(strContact As String)

Dim objOutlook As Outlook.Application
Dim nms As Outlook.NameSpace
Dim targetFolder As Outlook.MAPIFolder
Dim targetItems As Outlook.Items
Dim targetContact As Outlook.ContactItem
Dim strFilter As String

Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
Set targetFolder = nms.GetDefaultFolder(olFolderContacts)

'The [] around the property are required
'Not all ContactItems will have a FullName and example would be
'if you have a Company listed in your contacts where the company
'name is listed in the COMPANY field, but no FIRST/LAST Name is
'provided
strFilter = "[FullName]=" & Chr(34) & strContact & Chr(34)
Set targetItems = targetFolder.Items.Restrict(strFilter)

Debug.Print targetItems.Count

Stop

Set targetItems = Nothing
Set targetFolder = Nothing
Set nms = Nothing
Set objOutlook = Nothing

End Sub
hello, i have an access database that finds an outlook contact alias. (ex.
ABCDE) Is there any way i can have access search the contacts and return the
contact full name? I don't know if there is a way to open outlook, open
address book, search by alias and return contact full name. So for
example, the database returns ABCJD - opens outlook, opens address book,
searches for alias ABCJD and returns full name John Doe.

Is it possible?
 
G

Guest

Well, the value that i would be looking for (ex. ROSPL) is listed in the
"alias" field when the address book is open. If i try to search the address
book through the outlook search bar, it comes up. If i open the address
book and type in the value in the "type name or select from list" field, it
does not find it.

I'm not sure if there's any way to completely verify the exact field name i
am looking for.

David C. Holley said:
First, you need to confirm for certain that "NickName" is the field to
search. Doesn't help to search your daughter's dresser for your son't
baseball bat.


Thanks for the response. Sorry about the lateness, i've been away.
2 things i need to add. First, the string being searched for is being found
by a query in a calculated field. It is not stored anywhere. I'm not sure if
the code below reflects that. How would you pass the value from the access
query to the code?

Second, i'm guessing the alias field is called the "NickName" field in the
outlook object model. That's the closest thing i could find to alias.
Any more help would be greatly appreciated.

Thanks

:

YES. This should get you started, however there isn't an ALIAS property
for ContactItems listed in the Outlook Object Model/Outlook Help. Which
property where you referring to? (The code below only looks in the
default Contact folder. I'm checking on how to loop through all folders.)

Sub snoopContacts(strContact As String)

Dim objOutlook As Outlook.Application
Dim nms As Outlook.NameSpace
Dim targetFolder As Outlook.MAPIFolder
Dim targetItems As Outlook.Items
Dim targetContact As Outlook.ContactItem
Dim strFilter As String

Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
Set targetFolder = nms.GetDefaultFolder(olFolderContacts)

'The [] around the property are required
'Not all ContactItems will have a FullName and example would be
'if you have a Company listed in your contacts where the company
'name is listed in the COMPANY field, but no FIRST/LAST Name is
'provided
strFilter = "[FullName]=" & Chr(34) & strContact & Chr(34)
Set targetItems = targetFolder.Items.Restrict(strFilter)

Debug.Print targetItems.Count

Stop

Set targetItems = Nothing
Set targetFolder = Nothing
Set nms = Nothing
Set objOutlook = Nothing

End Sub

bgcpen wrote:

hello, i have an access database that finds an outlook contact alias. (ex.
ABCDE) Is there any way i can have access search the contacts and return the
contact full name? I don't know if there is a way to open outlook, open
address book, search by alias and return contact full name. So for
example, the database returns ABCJD - opens outlook, opens address book,
searches for alias ABCJD and returns full name John Doe.

Is it possible?
 
D

David C. Holley

Unfortunately, the only techniques that I know rely on knowning exactly
in which field the value lies. How are the Contacts originally created
via code or manually entered? If its by code, do you have access to it
as the code would reveal which field we're dealing with.
Well, the value that i would be looking for (ex. ROSPL) is listed in the
"alias" field when the address book is open. If i try to search the address
book through the outlook search bar, it comes up. If i open the address
book and type in the value in the "type name or select from list" field, it
does not find it.

I'm not sure if there's any way to completely verify the exact field name i
am looking for.

:

First, you need to confirm for certain that "NickName" is the field to
search. Doesn't help to search your daughter's dresser for your son't
baseball bat.


Thanks for the response. Sorry about the lateness, i've been away.
2 things i need to add. First, the string being searched for is being found
by a query in a calculated field. It is not stored anywhere. I'm not sure if
the code below reflects that. How would you pass the value from the access
query to the code?

Second, i'm guessing the alias field is called the "NickName" field in the
outlook object model. That's the closest thing i could find to alias.
Any more help would be greatly appreciated.

Thanks

:



YES. This should get you started, however there isn't an ALIAS property
for ContactItems listed in the Outlook Object Model/Outlook Help. Which
property where you referring to? (The code below only looks in the
default Contact folder. I'm checking on how to loop through all folders.)

Sub snoopContacts(strContact As String)

Dim objOutlook As Outlook.Application
Dim nms As Outlook.NameSpace
Dim targetFolder As Outlook.MAPIFolder
Dim targetItems As Outlook.Items
Dim targetContact As Outlook.ContactItem
Dim strFilter As String

Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
Set targetFolder = nms.GetDefaultFolder(olFolderContacts)

'The [] around the property are required
'Not all ContactItems will have a FullName and example would be
'if you have a Company listed in your contacts where the company
'name is listed in the COMPANY field, but no FIRST/LAST Name is
'provided
strFilter = "[FullName]=" & Chr(34) & strContact & Chr(34)
Set targetItems = targetFolder.Items.Restrict(strFilter)

Debug.Print targetItems.Count

Stop

Set targetItems = Nothing
Set targetFolder = Nothing
Set nms = Nothing
Set objOutlook = Nothing

End Sub

bgcpen wrote:


hello, i have an access database that finds an outlook contact alias. (ex.
ABCDE) Is there any way i can have access search the contacts and return the
contact full name? I don't know if there is a way to open outlook, open
address book, search by alias and return contact full name. So for
example, the database returns ABCJD - opens outlook, opens address book,
searches for alias ABCJD and returns full name John Doe.

Is it possible?
 
G

Guest

The contacts are in the global address book on an exchange server. I have no
access to them. I'm not sure how they were created either. I guess i will
keep trying to research it. Thanks for your help!

David C. Holley said:
Unfortunately, the only techniques that I know rely on knowning exactly
in which field the value lies. How are the Contacts originally created
via code or manually entered? If its by code, do you have access to it
as the code would reveal which field we're dealing with.
Well, the value that i would be looking for (ex. ROSPL) is listed in the
"alias" field when the address book is open. If i try to search the address
book through the outlook search bar, it comes up. If i open the address
book and type in the value in the "type name or select from list" field, it
does not find it.

I'm not sure if there's any way to completely verify the exact field name i
am looking for.

:

First, you need to confirm for certain that "NickName" is the field to
search. Doesn't help to search your daughter's dresser for your son't
baseball bat.



bgcpen wrote:

Thanks for the response. Sorry about the lateness, i've been away.
2 things i need to add. First, the string being searched for is being found
by a query in a calculated field. It is not stored anywhere. I'm not sure if
the code below reflects that. How would you pass the value from the access
query to the code?

Second, i'm guessing the alias field is called the "NickName" field in the
outlook object model. That's the closest thing i could find to alias.
Any more help would be greatly appreciated.

Thanks

:



YES. This should get you started, however there isn't an ALIAS property
for ContactItems listed in the Outlook Object Model/Outlook Help. Which
property where you referring to? (The code below only looks in the
default Contact folder. I'm checking on how to loop through all folders.)

Sub snoopContacts(strContact As String)

Dim objOutlook As Outlook.Application
Dim nms As Outlook.NameSpace
Dim targetFolder As Outlook.MAPIFolder
Dim targetItems As Outlook.Items
Dim targetContact As Outlook.ContactItem
Dim strFilter As String

Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
Set targetFolder = nms.GetDefaultFolder(olFolderContacts)

'The [] around the property are required
'Not all ContactItems will have a FullName and example would be
'if you have a Company listed in your contacts where the company
'name is listed in the COMPANY field, but no FIRST/LAST Name is
'provided
strFilter = "[FullName]=" & Chr(34) & strContact & Chr(34)
Set targetItems = targetFolder.Items.Restrict(strFilter)

Debug.Print targetItems.Count

Stop

Set targetItems = Nothing
Set targetFolder = Nothing
Set nms = Nothing
Set objOutlook = Nothing

End Sub

bgcpen wrote:


hello, i have an access database that finds an outlook contact alias. (ex.
ABCDE) Is there any way i can have access search the contacts and return the
contact full name? I don't know if there is a way to open outlook, open
address book, search by alias and return contact full name. So for
example, the database returns ABCJD - opens outlook, opens address book,
searches for alias ABCJD and returns full name John Doe.

Is it possible?
 
D

David C. Holley

The GAL changes everthing. I was assuming that you were searching your
private Contacts folder. Post the message here:

microsoft.public.outlook.program_vba

They'll be able to answer the question.
The contacts are in the global address book on an exchange server. I have no
access to them. I'm not sure how they were created either. I guess i will
keep trying to research it. Thanks for your help!

:

Unfortunately, the only techniques that I know rely on knowning exactly
in which field the value lies. How are the Contacts originally created
via code or manually entered? If its by code, do you have access to it
as the code would reveal which field we're dealing with.
Well, the value that i would be looking for (ex. ROSPL) is listed in the
"alias" field when the address book is open. If i try to search the address
book through the outlook search bar, it comes up. If i open the address
book and type in the value in the "type name or select from list" field, it
does not find it.

I'm not sure if there's any way to completely verify the exact field name i
am looking for.

:



First, you need to confirm for certain that "NickName" is the field to
search. Doesn't help to search your daughter's dresser for your son't
baseball bat.



bgcpen wrote:


Thanks for the response. Sorry about the lateness, i've been away.
2 things i need to add. First, the string being searched for is being found
by a query in a calculated field. It is not stored anywhere. I'm not sure if
the code below reflects that. How would you pass the value from the access
query to the code?

Second, i'm guessing the alias field is called the "NickName" field in the
outlook object model. That's the closest thing i could find to alias.
Any more help would be greatly appreciated.

Thanks

:




YES. This should get you started, however there isn't an ALIAS property
for ContactItems listed in the Outlook Object Model/Outlook Help. Which
property where you referring to? (The code below only looks in the
default Contact folder. I'm checking on how to loop through all folders.)

Sub snoopContacts(strContact As String)

Dim objOutlook As Outlook.Application
Dim nms As Outlook.NameSpace
Dim targetFolder As Outlook.MAPIFolder
Dim targetItems As Outlook.Items
Dim targetContact As Outlook.ContactItem
Dim strFilter As String

Set objOutlook = CreateObject("Outlook.application")
Set nms = objOutlook.GetNamespace("MAPI")
Set targetFolder = nms.GetDefaultFolder(olFolderContacts)

'The [] around the property are required
'Not all ContactItems will have a FullName and example would be
'if you have a Company listed in your contacts where the company
'name is listed in the COMPANY field, but no FIRST/LAST Name is
'provided
strFilter = "[FullName]=" & Chr(34) & strContact & Chr(34)
Set targetItems = targetFolder.Items.Restrict(strFilter)

Debug.Print targetItems.Count

Stop

Set targetItems = Nothing
Set targetFolder = Nothing
Set nms = Nothing
Set objOutlook = Nothing

End Sub

bgcpen wrote:



hello, i have an access database that finds an outlook contact alias. (ex.
ABCDE) Is there any way i can have access search the contacts and return the
contact full name? I don't know if there is a way to open outlook, open
address book, search by alias and return contact full name. So for
example, the database returns ABCJD - opens outlook, opens address book,
searches for alias ABCJD and returns full name John Doe.

Is it possible?
 

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

Top