A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: , , , , , ,

Check if an address is in the recipient list including distribution lists?





 
 
Thread Tools Display Modes
  #1  
Old January 26th 06, 10:15 PM posted to microsoft.public.outlook.program_vba
PilotYid
external usenet poster
 
Posts: 3
Default Check if an address is in the recipient list including distribution lists?

Basically, In my Application_ItemSend I would like to check if a
particular person or persons are in the recipient list (To or CC). I
tried this by looping through mailItem.Recipients and checking each
one. Problem is that this won't look inside of distribution lists, so
if I send to a distribution list that has this person in it, this won't
detect it. How can I do this? Any way to expand the dist. list at this
point to look inside, and/or determine if a particular recipient is a
dist list?

Thanks for your help,
Aaron

Ads
  #2  
Old January 27th 06, 12:32 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 1,522
Default Check if an address is in the recipient list including distribution lists?

You can access DL members using the Recipient.AddressEntry.Members
collection

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"PilotYid" wrote in message
ups.com...
Basically, In my Application_ItemSend I would like to check if a
particular person or persons are in the recipient list (To or CC). I
tried this by looping through mailItem.Recipients and checking each
one. Problem is that this won't look inside of distribution lists, so
if I send to a distribution list that has this person in it, this won't
detect it. How can I do this? Any way to expand the dist. list at this
point to look inside, and/or determine if a particular recipient is a
dist list?

Thanks for your help,
Aaron



  #3  
Old January 27th 06, 03:34 AM posted to microsoft.public.outlook.program_vba
PilotYid
external usenet poster
 
Posts: 3
Default Check if an address is in the recipient list including distribution lists?

Thanks. When I am looping through the recepients on the email, how do I
know if it is a DL so I can know to check the Members collection? Or do
all recepients have a Members collection, but are just size 1 for
regular addresses? Would you mind giving me a small code sample?

Thanks again

  #4  
Old January 27th 06, 04:55 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 1,522
Default Check if an address is in the recipient list including distribution lists?

For the DLs the Members property is non-NULL.
Or chekc that the AddressEntry.DisplayType property is set to olDistList or
olPrivateDistList.

sub ProcessAddressEntry(AddressEntry)
if (AddressEntry = olDistList) or (AddressEntry = olPrivateDistList)
Then
for i = 1 to AddressEntry.Members.Count
ProcessAddressEntry AddressEntry.Members(i)
next
Else
Debug.Print AddressEntry.Address
End If
end sub
....
for i = 1 to MailItem.Recipients.Count
set AddressEntry = MailItem.Recipients(i).AddressEntry
if not (AddressEntry Is Nothing) Then
ProcessAddressEntry(AddressEntry)
End If
next

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"PilotYid" wrote in message
oups.com...
Thanks. When I am looping through the recepients on the email, how do I
know if it is a DL so I can know to check the Members collection? Or do
all recepients have a Members collection, but are just size 1 for
regular addresses? Would you mind giving me a small code sample?

Thanks again



  #5  
Old February 1st 06, 12:24 PM posted to microsoft.public.outlook.program_vba
PilotYid
external usenet poster
 
Posts: 3
Default Check if an address is in the recipient list including distribution lists?

Thanks for your help. For some reason, the distribution lists in my
company are showing up as displaytype 0, not DistList or
PrivateDistList. Do you have any ideas why this would be? Is there
another way to do this?
Thanks again

Dmitry Streblechenko wrote:
For the DLs the Members property is non-NULL.
Or chekc that the AddressEntry.DisplayType property is set to olDistList or
olPrivateDistList.

sub ProcessAddressEntry(AddressEntry)
if (AddressEntry = olDistList) or (AddressEntry = olPrivateDistList)
Then
for i = 1 to AddressEntry.Members.Count
ProcessAddressEntry AddressEntry.Members(i)
next
Else
Debug.Print AddressEntry.Address
End If
end sub
...
for i = 1 to MailItem.Recipients.Count
set AddressEntry = MailItem.Recipients(i).AddressEntry
if not (AddressEntry Is Nothing) Then
ProcessAddressEntry(AddressEntry)
End If
next

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"PilotYid" wrote in message
oups.com...
Thanks. When I am looping through the recepients on the email, how do I
know if it is a DL so I can know to check the Members collection? Or do
all recepients have a Members collection, but are just size 1 for
regular addresses? Would you mind giving me a small code sample?

Thanks again


  #6  
Old February 1st 06, 05:57 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 1,522
Default Check if an address is in the recipient list including distribution lists?

Are you sure? 0 is olUser. Are you using Exchange? Did you try to test if
the Members collection is non NULL?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"PilotYid" wrote in message
ps.com...
Thanks for your help. For some reason, the distribution lists in my
company are showing up as displaytype 0, not DistList or
PrivateDistList. Do you have any ideas why this would be? Is there
another way to do this?
Thanks again

Dmitry Streblechenko wrote:
For the DLs the Members property is non-NULL.
Or chekc that the AddressEntry.DisplayType property is set to olDistList
or
olPrivateDistList.

sub ProcessAddressEntry(AddressEntry)
if (AddressEntry = olDistList) or (AddressEntry = olPrivateDistList)
Then
for i = 1 to AddressEntry.Members.Count
ProcessAddressEntry AddressEntry.Members(i)
next
Else
Debug.Print AddressEntry.Address
End If
end sub
...
for i = 1 to MailItem.Recipients.Count
set AddressEntry = MailItem.Recipients(i).AddressEntry
if not (AddressEntry Is Nothing) Then
ProcessAddressEntry(AddressEntry)
End If
next

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"PilotYid" wrote in message
oups.com...
Thanks. When I am looping through the recepients on the email, how do I
know if it is a DL so I can know to check the Members collection? Or do
all recepients have a Members collection, but are just size 1 for
regular addresses? Would you mind giving me a small code sample?

Thanks again




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Distribution Lists tweeks Outlook - Using Contacts 12 December 19th 07 12:59 AM
Distribution lists hdboater Outlook - Using Contacts 4 March 5th 06 08:28 PM
distribution lists Mike Outlook - Using Contacts 3 February 21st 06 04:01 AM
create new distribution list in global address lists in exchange tim Outlook - Using Contacts 1 February 6th 06 09:52 PM
how do I print a distribution list from a global address book? Sue Mosher [MVP-Outlook] Outlook - Using Contacts 0 January 18th 06 05:11 PM


All times are GMT +1. The time now is 09:39 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2008 Outlook Banter, part of the NewsgroupBanter project.
The comments are property of their posters.
Fast Loans - Loans - Mortgages - MPAA - Problem Mortgage