The Add method adds a recipient to the recipient list (MSMQMailRecipientList) or a field to a form field list (MSMQMailFormFieldList).
object1.object2.Add Name, Address, Type[, DeliveryTime][, NonDeliveryReason][, Key]
Syntax Element | Description |
---|---|
object1 | E-mail message (MSMQMailEMail) object that defines the e-mail message. |
object2 | Recipient list (MSMQMailRecipientList) object that represents the list of recipients. |
Name | String representation of recipient. |
Address | String representation of the e-mail recipient's address. Use one of the following formats (see Remarks for examples). When the e-mail is being sent to another MSMQ application, the recipient's address is the label (Label) of the application input queue. Address:="MSMQQueueLabel" When the e-mail is being sent to a Microsoft Exchange user via the MSMQ Exchange Connector, the address includes the e-mail alias of the Exchange user plus the label of the Exchange Connector's server input queue. Address:="UserName@ServerInputQueueLabel" When e-mail is being sent to the MAPI Transport Provider, the address is the label of the MAPI user input queue. Address:="UserInputQueueLabel" |
Type | The Type parameter can have any one of the following values: MSMQMAIL_RECIPIENT_TO: Default. The recipient is the primary recipient of the e-mail. MSMQMAIL_RECIPIENT_CC: The e-mail is copied to the recipient. MSMQMAIL_RECIPIENT_BCC: The e-mail is blind copied to the recipient. |
DeliveryTime | Optional. DeliveryTime is only used when adding a recipient to the DeliveredRecipients property of the MSMQMailDeliveryReportData object. This property specifies when the original e-mail was delivered to the recipient. |
NonDeliveryReason | Optional. NonDeliveryReason is only used when adding a recipient to the NonDeliveredRecipients property of the MSMQMailNonDeliveryReportData object. This property specifies the reason why the original e-mail was not delivered to the recipient. |
Key | Optional. Key (Variant type) used when removing the recipient from the recipient list (see IndexKey parameter of Remove). |
object1.object2.object3.Add Name, Value[, Key]
Syntax Element | Description |
---|---|
object1 | E-mail message (MSMQMailEMail) object that defines the e-mail message. |
object2 | Form field data (MSMQMailFormData) object that defines the form. |
object3 | Form field list (MSMQMailFormFieldList) object that represents the list of fields in the form. |
Name | String representation of the name of the field. This name should correspond to the name of the field's Reference Name as specified in the Exchange Form Designer. The Reference Name can be found on the General page of the Field Properties dialog of the Exchange Form Designer. If the correct Reference Name is not used, Microsoft Exchange may not display the field correctly. |
Value | String, Integer, Boolean, Double, or Currency value of field. |
Key | Optional. Key used when removing the field from the form field list (see IndexKey parameter of Remove). |
This example defines an e-mail message with two recipients and then displays the name and address of each recipient. The addresses of the recipients indicate that the mail will be sent to the Exchange Connector (first recipient) and the MAPI Transport Provider (second recipient).
Note For examples of setting the NonDeliveryReason and DeliveryTime parameters, see the examples in NonDeliveryReason and DeliveryTime properties respectively.
To try this example using Microsoft® Visual Basic® (version 5.0), paste the code into the Code window of a form, run the example, and click the form.
Private Sub Form_Click()
Dim email As New MSMQMailEMail
'Set e-mail type to text message
email.ContentType= MSMQMAIL_EMAIL_TEXTMESSAGE
'**********************************
'* Add Exchange Connector recipient
'* as primary recipient.
'**********************************
email.Recipients.Add "Exchange_User", "ExchangeUser@ServerInputQueueLabel", MSMQMAIL_RECIPIENT_TO
'*********************
'* Add MAPI recipient
'* as CC recipient.
'*********************
email.Recipients.Add "MAPI_User", "MAPIUserInputQueueLabel", MSMQMAIL_RECIPIENT_CC
'Set who sent the e-mail.
email.Sender.Name = "Our name"
email.Sender.Address = "Our queue label"
'Set the subject of the e-mail.
email.Subject = "Test mail."
'Set the Body of the e-mail.
email.TextMessageData.Text = "This is the Body of the message."
'*********************
'* Display Recipients.
'*********************
Dim recipient As MSMQMailRecipient
For Each recipient In email.Recipients
MsgBox "Mail was sent to " + recipient.Name + " at " + recipient.Address
Next recipient
End Sub
This example defines an e-mail message with three fields (String, Boolean, and Date) and then displays the value given to each field.
To try this example using Microsoft Visual Basic (version 5.0), paste the code into the Code window of a form, run the example, and click the form.
Dim email As New MSMQMailEMail
Private Sub Form_Click()
'*********************
'* Define e-mail
'*********************
'Set e-mail type to form message.
email.ContentType = MSMQMAIL_EMAIL_FORM
'Add primary recipient.
email.Recipients.Add "Exchange_User", "ExchangeUser@ServerInputQueueLabel", MSMQMAIL_RECIPIENT_TO
'Set who sent the e-mail.
email.Sender.Name = "Our name"
email.Sender.Address = "Our queue label"
'Set the subject of the mail.
email.Subject = "Test form."
'**********************
'* Define the form.
'**********************
'Set the form name.
email.formdata.Name = "Test Form"
'Set form field list.
email.formdata.FormFields.Add "StringField", "Test Field"
email.formdata.FormFields.Add "BooleanField", True
email.formdata.FormFields.Add "DateField", "DateString"
'*********************
'* Display fields.
'*********************
Dim formfield As MSMQMailFormField
For Each formfield In email.formdata.FormFields
MsgBox "Form: " + formfield.Name + " = " + CStr(formfield.Value)
Next formfield
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.
Address, ContentType, FormData, FormFields, MSMQMailEMail, MSMQMailRecipient, Name, Recipients, Sender, Subject, Text, TextMessageData