The Remove method removes a specific recipient from the recipient list (MSMQMailRecipientList)or a field from the form field list (MSMQMailFormFieldList).
object1.object2.Remove IndexKey
Syntax Element | Description |
object1 | E-mail message (MSMQMailEMail) object that defines the e-mail message. |
object2 | Recipient (MSMQMailRecipientList) list object. |
IndexKey | Index of the Item array, or the key specified when the recipient was added to the list (see Key parameter of Add). |
object1.object2.object3.Remove IndexKey
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 (MSMQMailFormFieldList) list object. |
IndexKey | Index of the Item array, or the key specifies when the recipient or field was added to the list (see Key parameter of Add). |
This example creates an e-mail object with a primary, copy, and blind copy recipient, setting the index key on the blind-copy recipient. It then displays the names of the recipients, removes the blind-copy recipient using its index key, then displays the names of the recipients remaining in the form.
To try this example using Microsoft Visual Basic (version 5.0), paste the code into the Code window of a form, and then run the example and click the form.
Dim email As New MSMQMailEMail Private Sub Form_Click() 'Set e-mail type to text message email.ContentType = MSMQMAIL_EMAIL_TEXTMESSAGE '********************************** '* Add primary recipient. '********************************** email.Recipients.Add "Exchange_User", "ExchangeUser@ServerInputQueueLabel", MSMQMAIL_RECIPIENT_TO '********************* '* Add CC recipient. '********************* email.Recipients.Add "MAPI_User1", "MAPIUserInputQueueLabel", MSMQMAIL_RECIPIENT_CC '********************* '* Add BC recipient. '********************* email.Recipients.Add "MAPI_User2", "MAPIUserInputQueueLabel", MSMQMAIL_RECIPIENT_BCC, "BC" '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." '******************************* '* Remove blind-copy Recipients. '******************************* Dim recipient As MSMQMailRecipient Debug.Print "**Old Recipient List**" For Each recipient In email.Recipients Debug.Print recipient.Name Next recipient email.Recipients.Remove "BC" Debug.Print "**New Recipient List**" For Each recipient In email.Recipients Debug.Print recipient.Name Next recipient End Sub
This example creates an e-mail form with three fields, setting the index key of the date field. It then displays the names and values of all fields, removes the date field using its index key, then displays the names of the fields remaining in the form.
To try this example using Microsoft Visual Basic (version 5.0), paste the code into the Code window of a form, and then 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 subject of mail. email.Subject = "Test form." 'Set 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", "SentDate" '********************** '* Remove Date field. '********************** Dim formfield As MSMQMailFormField Debug.Print "**Old Field List**" For Each formfield In email.formdata.FormFields Debug.Print formfield.Name + ": " + CStr(formfield.Value) Next formfield email.formdata.FormFields.Remove "SentDate" Debug.Print "**New Field List**" For Each formfield In email.formdata.FormFields Debug.Print formfield.Name + ": " + CStr(formfield.Value) Next formfield End Sub
Add, Address, ContentType, FormData, FormFields, MSMQMailEMail, MSMQMailFormField, MSMQMailRecipient, Name, Recipients, Sender, Subject, Text, TextMessageData, Value