ImapUtilsGetImapDateTimeString Method (DateTime, Boolean, Boolean)
Returns the string containing the specified date and time value in the IMAP4 format.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
public static string GetImapDateTimeString(
	DateTime dt,
	bool includeTime,
	bool isUtc


Type: SystemDateTime
The date and time in UTC or local timezone.
Type: SystemBoolean
If true, the date, time, and timezone will be included into the resulting string; otherwise, only the date will be included.
Type: SystemBoolean
Indicates if dt is UTC time or local time. Ignored if includeTime is false.

Return Value

Type: String
The IMAP4 datetime string in "dd-MMM-yyyy HH:mm:ss +/-HHmm", "dd-MMM-yyyy HH:mm:ss", or "dd-MMM-yyyy" format.

When is true, the timezone part of the returned string will be "+0000"; otherwise, the local timezone in "+/-HHmm" format (such as "-0500" for EST). However, if includeTime is false, the time and timezone information will not be appended to the resulting string. "

When uploading messages with UploadMessage(MailMessage, String, String, String, Boolean, UidPlusResult) method, the datetime value can contain all 3 fields (date, time, and timezone). When searching messages with Search(Boolean, String, String) method, datetime values can contain only date field.

This sample prints UTC and local time versions of certain DateTime value as IMAP4-formatted strings.
using System;
using MailBee;
using MailBee.ImapMail;

class Sample
    static void Main(string[] args)
        // Assume it's 31-Dec-2005 20:00:00 (24 hrs clock) now,
        // and the local timezone is EST (UTC minus 5 hrs 0 mins).
        DateTime dtLocal = DateTime.Now;
        DateTime dtUtc = dtLocal.ToUniversalTime();

        Console.WriteLine(ImapUtils.GetImapDateTimeString(dtLocal, true, false));
        // The output: 31-Dec-2005 20:00:00 -0500

        Console.WriteLine(ImapUtils.GetImapDateTimeString(dtUtc, true, true));
        // The output: 01-Jan-2006 01:00:00 +0000

        Console.WriteLine(ImapUtils.GetImapDateTimeString(dtLocal, false, false));
        // The output: 31-Dec-2005

        Console.WriteLine(ImapUtils.GetImapDateTimeString(dtUtc, false, true));
        // The output: 01-Jan-2006
See Also