Posting Messages to a Public Folder

Posting Messages to a Public Folder

To post a message to a public folder, create a message within the public folder by adding it to the folder’s Messages collection. Then add your subject and message text as you would for other messages.

Note that for messages in public folders, you must also set a few more message properties than you would when sending a message to a recipient. When you post a message to a public folder, the components of the MAPI architecture that usually handle a message and set its properties do not manage the message. Your application must set the Sent and Unread properties to True, the Submitted property to False, and the TimeReceived and TimeSent properties to the current time.

When you are ready to make the message available, call the Update method. The message is not accessible by any other messaging user until you call Update.

You can identify yourself as the poster of the message by setting its Sender property. You can also post the message on behalf of another messaging user by setting the Sender property twice. For more information, see the Sender property of the Message object.

For more information on sending messages, see Creating and Sending a Message.

ms527519.787845a5-a0eb-4ef0-a02b-af44a9f76e33(en-us,EXCHG.10).gif

To create a message within a public folder

  1. Call the Messages collection’s Add method to create a Message object.
  2. Set the Message object’s ConversationIndex, ConversationTopic, Subject, Text, TimeReceived, TimeSent, and other message properties as desired.
  3. Set the Message object’s Sent and Unread properties to True, and the Submitted property to False.
  4. Call the Message object’s Update method.

Note that when you post a message, you must explicitly set the TimeSent and TimeReceived properties. When you send a message using the Send method, the MAPI system assigns the values of these properties for you. However, when you post the message with the Update method, your application must set the time properties. Set both time properties to the same value, just before you set the Sent property to True.

' Function: Util_New_Conversation
' Purpose: Set properties to start a new conversation in a public folder
Function Util_NewConversation()
Dim objRecipColl As Recipients
Dim i As Integer
Dim objNewMsg As Message ' new message object
Dim strNewIndex As String
On Error GoTo error_olemsg

' objPublicFolder is a global variable that indicates
' the folder in which you want to post the message
Set objNewMsg = objPublicFolder.Messages.Add
If objNewMsg Is Nothing Then
    MsgBox "unable to create a new message for the public folder"
    Exit Function
End If
strConversationFirstMsgID = objNewMsg.ID 'save for reply
With objNewMsg
    .Subject = "Used car wanted"
    .Text = "Wanted: Used car in good condition with low mileage."
    .ConversationTopic = .Subject
    .ConversationIndex = Util_GetEightByteTimeStamp() ' utility
    .TimeReceived = Time
    .TimeSent = .TimeReceived
    .Sent = True
    .Submitted = False
    .Unread = True
    .Update ' .Send is not used for posting to a folder
End With
Exit Function

error_olemsg:
MsgBox "Error " & Str(Err) & ": " & Error$(Err)
Resume Next

End Function
 

For more information on the ConversationIndex property, see Working With Conversations.

See Also

Searching for a Folder

See Also

Concepts

Programming Tasks