Using Redemption to extract SMTP Addresses

B

Benjie Legaspi

Can you use Redemption to extract the SMTP addresses of all items in a
recipient list if some are distribution lists? If this is possible,
can you process the recipients (possibly recursively) to handle the
case of distribution lists containing distribution lists?

Thanks for any help,

Benjie Legaspi
Florida Public Service Commission
 
D

Dmitry Streblechenko \(MVP\)

Try something like the following (assuming MailItem points to an existing
Outlook.MailItem object):

PR_SMTP_ADDRESS = &H39FE001E

sub ProcessAddressEntry(AddressEntry)
set Members =AddressEntry.Members
if Members Is Nothing Then
'regular recipient
if AddressEntry.Type = "EX" Then
Debug.Print(AddressEntry.Fields(PR_SMTP_ADDRESS))
Else
Debug.Print(AddressEntry.Address)
End If
Else
'Distribution list
for j = 1 to Members.Count
ProcessAddressEntry(Members.Item(j))
next
End If
end sub

set sItem = CreateObject("Redemption.SafeMailItem")
sItem.Item = MailItem
for i = 1 to sItem.Recipients.Count
set Recip = sItem.Recipients(i)
set AE = Recip.AddressEntry
if not (AE Is Nothing) Then
ProcessAddressEntry(AE)
End If
next



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

Benjamin Legaspi

Dmitry,

Thanks for taking the time to reply. I will try to incorporate your code
into my Outlook project. I honestly did not think it was possible to
process distribution lists recursively. Thanks also for the Redemption
class.

Benjie
 

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