This documentation is archived and is not being maintained.

How to: Delay sending an email message by using the EWS Managed API 2.0

EWS Managed API

Learn how to delay sending an email message by using the EWS Managed API.

Last modified: July 01, 2013

Applies to: EWS Managed API | Exchange Server 2007 Service Pack 1 (SP1) | Exchange Server 2010

Note: This content applies to the EWS Managed API 2.0 and earlier versions. For the latest information about the EWS Managed API, see Web services in Exchange.

In this article
Get started delaying email messages
Delay sending an email message
Next steps
Additional resources

Related code snippets and sample apps   Exchange 2013: Send delayed emails programmatically on Exchange servers

To get started using the EWS Managed API to delay sending email messages, complete the following tasks:

The following code example shows how to delay sending an email message. To use this code example, update the SMTP address in the To: recipients line.

// Delays the time that an email message is sent. 
static void DelaySendEmail(ExchangeService service)
   EmailMessage message = new EmailMessage(service);

   // Identify the extended properties that are used to set the time when the email message is sent.
   ExtendedPropertyDefinition PR_DEFERRED_SEND_TIME = new ExtendedPropertyDefinition(16367,
   // Identify when the email message will be sent and delivered. The email message is delivered three minutes after the
   // next line executes.
   string sendTime = DateTime.Now.AddMinutes(2).ToUniversalTime().ToString(); 

   // Set the extended properties with the dateTime for when the mail will be delivered.
   message.SetExtendedProperty(PR_DEFERRED_SEND_TIME, sendTime);

   message.Subject = "Test subject";

   StringBuilder str = new StringBuilder();
   str.AppendLine("Client submitted at: " + DateTime.Now.ToString());
   Console.WriteLine("Client submitted at: " + DateTime.Now.ToString());
   str.AppendLine("To be sent at: " + sendTime);
   Console.WriteLine("To be sent at: " + sendTime);

   message.Body = str.ToString();

This code example first creates an email message object, and then it creates an extended property definition to specify the MAPI property that is used to set the deferred send time. For more information about this property, see PidTagDeferredSendTime Canonical Property. The deferred send time information is set on the email message along with an email recipient, a subject, and the email message body. The message.SendAndSaveCopy() line results in a call to the service. If the call is successful, the email message will be available in the caller’s Outbox folder. After the email message is sent, a copy of the message will be created in the Sent Items folder.

This article shows how to delay sending an email message to a single recipient. Next, you might want to explore other ways that you can use the EWS Managed API to work with email messages. See the following articles: