The NonDeliveryReason property specifies why the original e-mail was not delivered.
Type: | String |
Run time: | Read-write |
object.NonDeliveryReason
Syntax Element | Description |
---|---|
Object | A recipient (MSMQMailRecipient) object that defines an e-mail recipient. |
Ffree text that describes the reason for not delivering the original e-mail to this recipient.
NonDeliveryReason has a valid value only when the recipient is a member of the NonDeliveredRecipients property of a non-delivery report e-mail.
This example defines a non-delivery report, adding two non-delivered recipients to the non-delivered recipient list of the report. The e-mail object is composed into a mail message, and each non-delivered recipient is displayed.
To try this example using Microsoft® Visual Basic® (version 5.0), build an original e-mail object in emailOrig, paste the code into the Code window of a form, enter a valid user address for each recipient, run the example, and click the form.
Dim email As New MSMQMailEMail
Dim msg As New MSMQMessage
Private Sub Form_Click()
'*********************
'* Define e-mail
'*********************
'Set e-mail type to non-delivery report.
email.ContentType = MSMQMAIL_EMAIL_NON_DELIVERY_REPORT
'Add the Recipient of the report (usually the original e-mail sender).
email.Recipients.Add "Exchange_User", "UserAlias@ServerInputQueueLabel", MSMQMAIL_RECIPIENT_TO
'Set original mail.
Set email.NonDeliveryReportData.OriginalEMail = emailOrig
'Add two non-delivered recipients.
email.NonDeliveryReportData.NonDeliveredRecipients.Add "Exchange_User2", "UserAlias2@ServerInputQueueLabel", MSMQMAIL_RECIPIENT_TO, NonDeliveryReason:= "Recipient was not available at this address"
email.NonDeliveryReportData.NonDeliveredRecipients.Add "Exchange_User3", "UserAlias3@ServerInputQueueLabel", MSMQMAIL_RECIPIENT_CC, NonDeliveryReason:= "Communication failure"
'Compose message Body
msg.Body = email.ComposeBody
'*********************
'* Display Delivered Recipients.
'*********************
Dim recipient As MSMQMailRecipient
For Each recipient In email.NonDeliveryReportData.NonDeliveredRecipients
MsgBox "Not Delivered To Recipient: " + recipient.Name + " at " + recipient.Address + ", Reason is:" + recipient.NonDeliveryReason
Next recipient
End Sub
Windows NT: Requires version 4.0 SP3 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Import Library: Included as a resource in mqmailoa.dll.
Unicode: Defined only as Unicode.
Add, Body, ComposeBody, ContentType, FormData, FormFields, MSMQMailEMail, MSMQMAILFormField, Name, ParseBody, Recipients, Subject, Text, TextMessageData, Value