Sample code for 30+ languages & platforms
Unicode C

MIME CurrentDateTime Property

See more MIME Examples

Demonstrates the read-only CurrentDateTime property, which returns the current local date and time formatted as an Internet message date including the numeric UTC offset. The example uses it to populate a Date header field.

Background. Internet message dates follow the RFC 5322 format, for example Fri, 21 Nov 1997 09:55:06 -0600. CurrentDateTime produces a value in that form for use in message headers.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkMimeW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkMimeW mime;
    const wchar_t *now;
    const wchar_t *head;

    success = FALSE;

    mime = CkMimeW_Create();
    success = CkMimeW_SetBodyFromPlainText(mime,L"Message with a Date header.");
    if (success == FALSE) {
        wprintf(L"%s\n",CkMimeW_lastErrorText(mime));
        CkMimeW_Dispose(mime);
        return;
    }

    //  CurrentDateTime returns the current local date and time formatted as an Internet message date,
    //  including the numeric UTC offset, for example: Fri, 21 Nov 1997 09:55:06 -0600
    now = CkMimeW_currentDateTime(mime);
    wprintf(L"Current date/time: %s\n",now);

    //  It can be used to populate a Date header field.
    CkMimeW_SetHeaderField(mime,L"Date",now);

    head = CkMimeW_getEntireHead(mime);
    if (CkMimeW_getLastMethodSuccess(mime) == FALSE) {
        wprintf(L"%s\n",CkMimeW_lastErrorText(mime));
        CkMimeW_Dispose(mime);
        return;
    }

    wprintf(L"%s\n",head);


    CkMimeW_Dispose(mime);

    }