NonDeliveredRecipients
MSMQMailNonDeliveryReportData

The NonDeliveredRecipients property specifies who did not receive the e-mail.

Type: MSMQMailRecipientList
Run time: Read-write

Syntax

object1.object2.NonDeliveredRecipients
 
Syntax Element Description
Object1 E-mail (MSMQMailEMail) object that defines the non-delivered report.
Object2 Non-delivery report data (MSMQMailNonDeliveryReportData) object that represents the non-delivery report information.

Settings

MSMQMailRecipientList object.

Remarks

Each recipient in the non-delivered recipient list is represented by an MSMQMailRecipient object. Each recipient object includes the name and address of the recipient, the input queue of the recipient, how the message was sent to recipient, and the reason why the original message was not delivered.

The NonDeliveryReason property of the MSMQMailRecipient object specifies why the original e-mail was not delivered to the recipient.

Example

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 non-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
 

QuickInfo

  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.

See Also

Add, Address, ComposeBody, ContentType, FormData, FormFields, MSMQMailEMail, Name, Sender, Subject, NonDeliveryReportData