ImapUtilsGetImapDateTimeString Method (DateTime, Boolean, String)
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: 12.5.0 build 687 for .NET 4.5
Syntax
public static string GetImapDateTimeString(
	DateTime dt,
	bool includeTime,
	string timeZoneOffset
)

Parameters

dt
Type: SystemDateTime
The date and time.
includeTime
Type: SystemBoolean
If true, the date, time, and timezone will be included into the resulting string; otherwise, only the date will be included.
timeZoneOffset
Type: SystemString
The timezone string in "+/-HHmm" format, or a null reference (Nothing in Visual Basic) if no timezone should be specified. 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.
Remarks

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.

Examples
This sample prints certain DateTime value as IMAP4-formatted string.
using System;
using MailBee;
using MailBee.ImapMail;

class Sample
{
    static void Main(string[] args)
    {
        // Assume it's 8 Apr 2006 14:45:50 (24 hrs clock) now,
        // and the local timezone is EDT (UTC minus 4 hrs 0 mins).
        DateTime dt = DateTime.Now;

        Console.WriteLine(ImapUtils.GetImapDateTimeString(dt, true, "-0400"));
        // The output: 08-Apr-2006 14:45:50 -0400

        Console.WriteLine(ImapUtils.GetImapDateTimeString(dt, false, "-0400"));
        // The output: 08-Apr-2006

        Console.WriteLine(ImapUtils.GetImapDateTimeString(dt, true, null));
        // The output: 08-Apr-2006 14:45:50
    }
}
See Also