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.
Note When posting messages in a public folder, you cannot use the CDO Library to set the Sender property. The Sender and related underlying properties are not present for a message created by the CDO Library.
For more information on sending messages, see Creating and Sending a Message.
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.