Share via


Add Method (Messages Collection)

Add Method (Messages Collection)

The Add method creates and returns a new AppointmentItem or Message object in the Messages collection.

Syntax

Set objMessage = objMsgColl.Add( [subject] [, text**] [, type] [, importance] )**

objMessage

On successful return, represents the new AppointmentItem or Message object added to the collection. The type of object added depends on the parent folder of the Messages collection.

objMsgColl

Required. The Messages collection object.

subject

Optional. String. The subject of the message. When this parameter is not supplied, the default value is an empty string.

text

Optional. String. The body text of the message. When this parameter is not supplied, the default value is an empty string.

type

Optional. String. The message class of the message, such as the default, IPM.Note.

importance

Optional. Long. The importance of the message. The following values are defined:

Constant

Value

Description

CdoLow

0

Low importance

CdoNormal

1

Normal importance (default)

CdoHigh

2

High importance

Remarks

The method parameters correspond to the Subject, Text, Type, and Importance properties of the Message object.

Note   If you are adding an AppointmentItem object to a calendar folder, you cannot use any of the parameters of the Add method. You can, however, set the values later by using the corresponding properties.

You should create new messages in the Inbox or Outbox folder, and new appointments in the calendar folder.

The user must have permission to Add or Delete a Message object. Most users have this permission in their mailbox and their Personal Folders.

The new Message object is saved in the MAPI system when you call its Update method.

Example

This code fragment replies to an original message:

' from the sample function Util_ReplyToConversation
Set objNewMsg = objSession.Outbox.Messages.Add
' verify objNewMsg created successfully ... then supply properties
Set objSenderAE = objOriginalMsg.Sender ' sender as AddressEntry
With objNewMsg
   .Text = "How about a slightly used bicycle?" ' new text
   .Subject = objOriginalMsg.Subject ' copy original properties
   .ConversationTopic = objOriginalMsg.ConversationTopic
   ' append time stamp; compatible with Microsoft Exchange client
   Set objOneRecip = .Recipients.Add( _
              Name:=objSenderAE.Name, _
              Address:=objSenderAE.Type & ":" & objSenderAE.Address, _
              Type:=CdoTo)
   .Recipients.Resolve
   .Update
   .Send showDialog:=False
End With
 

See Also

Concepts

Messages Collection Object