Recipients
Overview
The Recipients
property of a MailItem
class provides access to the collection of email recipients for the message.
Syntax
Return Value
A Recipients
collection object containing the recipients for the MailItem
.
Example
This example demonstrates how to create a mail item and work with recipients:
vba
Sub RecipientsExample()
Dim app As New nlsMailer.Application
Dim mailItem As Object
Dim recipients As Object
' Create a new mail item using the Application object
Set mailItem = app.CreateItem(olMailItem)
' Access the recipients collection
Set recipients = mailItem.Recipients
' Add recipients
Dim newRecipient As Object
Set newRecipient = recipients.Add("john.doe@example.com")
Set newRecipient = recipients.Add("jane.smith@example.com")
Set newRecipient = recipients.Add("team@company.com")
' Check the number of recipients
Debug.Print "Total Recipients: " & recipients.Count
' Iterate through recipients
Dim i As Long
Dim recipient As Object
For i = 1 To recipients.Count
Set recipient = recipients.Item(i)
' Display recipient details
Debug.Print "Recipient " & i & ": " & recipient.Address
Debug.Print "Recipient Type: " & recipient.RecipientType
Next i
End Sub