The Count property indicates the number of recipients in the recipient list or the number of fields in the field list.
Type: | Long |
Run time: | Read-only |
object1.object2.Count
Syntax Element | Description |
---|---|
object1 | E-mail message (MSMQMailEMail) object that defines the e-mail message. |
object2 | The recipient list (MSMQMailRecipientList) object that defines the list of recipients. |
object1.object2.object3.Count
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 | The field list (MSMQMailFormFieldList) object that defines the fields on a form. |
Number of items in list.
Count is updated each time the Add or Remove method of either list object (MSMQMailRecipientList or MSMQMailFormFieldList) is called.
This example defines an e-mail object, adds three recipients to the recipient list, and displays the number of recipients followed by the name of each recipient.
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()
'Set e-mail type to text message
email.ContentType = MSMQMAIL_EMAIL_TEXTMESSAGE
'**********************************
'* Add Recipients.
'**********************************
email.Recipients.Add "Exchange_User", "ExchangeUser@ServerInputQueueLabel", MSMQMAIL_RECIPIENT_TO
email.Recipients.Add "MAPI_User1", "MAPIUserInputQueueLabel", MSMQMAIL_RECIPIENT_CC
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."
'*******************************
'* Count recipient.
'*******************************
Dim recipient As MSMQMailRecipient
Debug.Print "**Number of Recipient in List**"
Debug.Print CStr(email.Recipients.Count)
Debug.Print "**Recipients**"
For Each recipient In email.Recipients
Debug.Print recipient.Name
Next recipient
End Sub
This example defines an e-mail object as a form, adds three fields to the form, and displays the number of fields followed by each field name.
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 subject of the 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"
'*******************************
'* Count fields.
'*******************************
Dim formfield As MSMQMailFormField
Debug.Print "**Number of Fields in Form**"
Debug.Print CStr(email.formdata.FormFields.Count)
Debug.Print "**Fields**"
For Each formfield In email.formdata.FormFields
Debug.Print formfield.Name
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.
Add, Address, ContentType, FormData, FormFields, MSMQMailEMail, MSMQMailFormField, MSMQMailRecipient, Name, Recipients, Sender, Subject, Text, TextMessageData