ImapUtilsGetImapDateTimeString Method (DateTime, Boolean, String) |
Returns the string containing the specified date and time value in the IMAP4 format.
Namespace: MailBee.ImapMailAssembly: 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
)
Public Shared Function GetImapDateTimeString (
dt As DateTime,
includeTime As Boolean,
timeZoneOffset As String
) As String
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:
StringThe 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)
{
DateTime dt = DateTime.Now;
Console.WriteLine(ImapUtils.GetImapDateTimeString(dt, true, "-0400"));
Console.WriteLine(ImapUtils.GetImapDateTimeString(dt, false, "-0400"));
Console.WriteLine(ImapUtils.GetImapDateTimeString(dt, true, null));
}
}
Imports System
Imports MailBee
Imports MailBee.ImapMail
Module Sample
Sub Main(ByVal args As String())
Dim dt As DateTime = DateTime.Now
Console.WriteLine(ImapUtils.GetImapDateTimeString(dt, True, "-0400"))
Console.WriteLine(ImapUtils.GetImapDateTimeString(dt, False, "-0400"))
Console.WriteLine(ImapUtils.GetImapDateTimeString(dt, True, CType(Nothing, String)))
End Sub
End Module
See Also