Resending an Undelivered Message
A transport provider sends a nondelivery report (NDR) when it cannot successfully deliver a message that you have submitted. It is up to the client whether or not users can attempt to resend these undelivered messages. If you support resending messages, you can either use a form provided by MAPI or implement your own. The MAPI form displays the names of the failed recipients and the reason for the delivery failure, if possible, and includes a button that, when selected, allows a user to resend the message.
When a resent message is received, it should look exactly like the original message. The recipient should be unable to differentiate between a message that was delivered on its first attempt at transmission or a subsequent attempt. Replies on this message should work exactly as if the message had been sent successfully the first time.
To resend an undelivered message
-
Call IMAPIFolder::CreateMessage to create a new message.
-
Copy all of the properties from the original message, excluding PR_MESSAGE_RECIPIENTS, the PR_SENDER properties, and the PR_SENT_REPRESENTING properties. Make the following property modifications:
-
Set PR_MESSAGE_CLASS to the report's PR_ORIG_MESSAGE_CLASS property.
-
Set the MSGSTATUS_RESEND flag in the PR_MESSAGE_FLAGS property.
-
Set PR_ORIGINAL_ENTRYID to the original message's PR_ENTRYID property.
-
For each recipient, set MAPI_SUBMITTED in the PR_RECIPIENT_TYPE property.
-
Duplicate each failed recipient. Change the PR_RECIPIENT_TYPE property for the duplicated recipient to MAPI_P1. Therefore, for each failed recipient there are now two entries in the recipient table: one with PR_RECIPIENT_TYPE set to its original value and the other with PR_RECIPIENT_TYPE set to MAPI_P1.
-
Call ScCreateConversationIndex to set up conversation tracking if desired.
-
Call the new message's IMessage::ModifyRecipients method to update the recipient list.
-
Call IMessage::SubmitMessage to save and send the new message.