Microsoft KB Archive/195381

= HOWTO: Use CDO (1.x) to Set the Message Delivery Options =

Article ID: 195381

Article Last Modified on 7/13/2004

-

APPLIES TO


 * Microsoft Collaboration Data Objects 1.1
 * Microsoft Collaboration Data Objects 1.2
 * Microsoft Collaboration Data Objects 1.21

-



This article was previously published under Q195381



SUMMARY
This article demonstrates how to create a message using Collaboration Data Objects (1.1, 1.2, 1.21) and then sets the deferred delivery time and message expiration time settings. This can be useful for sending time sensitive messages programmatically.



MORE INFORMATION
This sample creates a message and sets the message to be sent at 10:00 AM. It also sets the message to expire at 6:00 PM.  Create a new Visual Basic project and add a reference to the Microsoft CDO (1.1, 1.2, 1.21) Library. Add a command button to the form and set the caption to "Set send options".  In the Click event of the "Set send options" command button, add the following code: Dim oSession As MAPI.Session Dim oOutbox As Folder Dim omessage As Message Dim oRecip As Recipient

' Create the session and log on. Set oSession = CreateObject("mapi.session") oSession.Logon

' Get the outbox and add the message. Set oOutbox = oSession.Outbox Set omessage = oOutbox.Messages.Add

' Set the properties on message. Set oRecip = omessage.Recipients.Add oRecip.Name = "conference room" oRecip.Resolve omessage.Subject = "Test message with send options set" omessage.Text = "This is the body."

' Setting the delivery time and the Expiry settings for the message. ' The property setting times are in a 24 hour format. ' Message sending options: ' CdoPR_DEFERRED_DELIVERY_TIME = &HF0040 ' CdoPR_EXPIRY_TIME            = &H150040

' This message will be delivered at 10:00 AM on October 23, 1998 omessage.Fields.Item(CdoPR_DEFERRED_DELIVERY_TIME) = _ "1998/10/23 10:00:00"

' This message will expire at 6:00 PM on October 23, 1998 omessage.Fields.Item(CdoPR_EXPIRY_TIME) = "1998/10/23 18:00:00"

' Update the message and send it. omessage.Update omessage.Send

' Logoff and cleanup oSession.Logoff Set oSession = Nothing  Compile and run the form.

Deferred messages are spooled from the Outbox to a hidden folder on the server. Only unread items are affected by the expiration time you specify. At the time that the expiration is set, the message will be marked with a strikeout font in the Inbox. In addition, the header on the message indicates that the message expired at that time.

