Retrieving the x-receiver list from a CDO Message using the Fields Collection

D

David Morgan

Hello

I am trying to write a routine that will retrieve all the messages in my
SMTP Service Drop Folder and process them one by one based on the
address(es) to which the mail was sent.

When accessed via a CDO.Message each message in the drop folder has an
x-receiver field present containing only the email address of the reciepient
that caused the message to arrive on my server. This is useful because I
don't have to check the To, CC and BCC fields or strip out names from
addresses that are formated like "Forename Surname"
<[email protected]>.

I can then look up the receiver in my database based on the email address
alone.

The problem is that if a message is sent to two people on my server, there
will be two x-receiver lines in the email but the fields collection only
contains one. I guess this might be due to naming or something, as two
fields can't have the same name, but how do I get the full list of
recipients.

I have looked in to smtpenvelope/recipientlist and a few other things, but
they are either not present or do not work.

Has anyone come across this before or have any ideas?

Code so far, which lists all the fields and only shows the first x-receiver
when the email starts with two:

Set objDropDir = CreateObject("CDO.DropDirectory")
Set objMessages = objDropDir.GetMessages(DROP_DIR)

iMessages = objMessages.Count

If iMessages > 0 Then
For iMessage = iMessages To 1 Step -1
For Each objField In objMessages.Item(iMessage).Fields
MsgBox objField.Name & ": " & objField.Value
Next

Sample email snip:

x-sender: (e-mail address removed)
x-receiver: (e-mail address removed)
x-receiver: (e-mail address removed)


Thanks

David
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top