Sample code for 30+ languages & platforms
PureBasic

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 PureBasic Downloads

PureBasic
IncludeFile "CkMime.pb"

Procedure ChilkatExample()

    success.i = 0

    mime.i = CkMime::ckCreate()
    If mime.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success = CkMime::ckSetBodyFromPlainText(mime,"Message with a Date header.")
    If success = 0
        Debug CkMime::ckLastErrorText(mime)
        CkMime::ckDispose(mime)
        ProcedureReturn
    EndIf

    ;  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.s = CkMime::ckCurrentDateTime(mime)
    Debug "Current date/time: " + now

    ;  It can be used to populate a Date header field.
    CkMime::ckSetHeaderField(mime,"Date",now)

    head.s = CkMime::ckGetEntireHead(mime)
    If CkMime::ckLastMethodSuccess(mime) = 0
        Debug CkMime::ckLastErrorText(mime)
        CkMime::ckDispose(mime)
        ProcedureReturn
    EndIf

    Debug head


    CkMime::ckDispose(mime)


    ProcedureReturn
EndProcedure