The Add method creates and returns a new Recipient object in the Recipients collection.
Set objRecip = collRecips.Add( [name] [, address] [, type])
Recipient type | Value | Description |
---|---|---|
CdoTo | 1 | The recipient is on the To line (default). |
CdoCc | 2 | The recipient is on the Cc line. |
CdoBcc | 3 | The recipient is on the Bcc line. |
The name, address, and type parameters correspond to the Recipient object's Name, Address, and Type properties, respectively.
When no parameters are present, an empty Recipient object is created.
The new recipient is saved in persistent storage when you call the Send method on the Message object containing the Recipients collection.
The Add method returns CdoE_NO_ACCESS when called on a message in the Inbox.
The CDO for NTS Library does not permit any modifications to messages in the Inbox, other than deleting the entire message. Prohibited modifications include adding, deleting, or modifying any attachment; adding, deleting, or modifying any recipient; and modifying any message property, even one with read/write access.
This code fragment adds a recipient to a message using information from an existing valid AddressEntry object
' from the sample function "Using Addresses"
' assume valid address entry ID from an existing message
Set objRecip = objNewMessage.Recipients.Add(type:=CdoTo, _
name:=objAdrEnt.Name)
objRecip.Address = objAddrEnt.Type & ":" & objAddrEnt.Address
' ** the preceding line is not strictly necessary with CDO for NTS,
' ** but it allows this code to run with CDO for Exchange, where
' ** Recipient.Address requires a FULL address concatenated from
' ** AddressEntry.Type, ":", and AddressEntry.Address
If objRecip Is Nothing Then
MsgBox "Unable to add existing AddressEntry using ID"
Exit Function
End If
objNewMessage.Text = "Expect 1 recipient."
MsgBox ("Count = " & objNewMessage.Recipients.Count)