The Mail.DSNHeaders collection contains the list of header fields contained in a DSN message. See the Collection Object for standard collection properties and methods.
Item = Mail.DSNHeaders(key|index)
Returns a Variant of type String.
The DSNHeaders collection may contain the following field:
Original-Envelope-ID | Contains an "envelope identifier" which uniquely identifies the transaction during which the message was submitted. This fields correspond to what is set using the Mail.DSNEnvID property. |
Reporting-MTA | Indicates the MTA which attempted to perform the delivery, relay, or gateway operation described in the DSN. This field is always present. |
DSN-Gateway | Indicates the name of the gateway or MTA which translated a foreign (non-Internet) delivery status notification into this DSN |
Received-From-MTA | Indicates the name of the MTA from which the message was received. |
Arrival-Date | Indicates the date and time at which the message arrived at the Reporting MTA. |
See RFC1894
for details about DSN messages.
The following example uses the Original-Envelope-ID to link back to the original receivers database record
Sub Mail_OnReceiveMail
If Mail.DSNHeaders("Original-Envelope-ID") <>
"" Then
sSQL = "SELECT * FROM MyContacts
WHERE ContactID=" & Mail.DSNHeaders("Original-Envelope-ID")
' Execute SQL
query...
' Update
record...
End If
End Sub
DSNReceivers, DSNEnvID, Collection Object