Sample code for 30+ languages & platforms
Tcl

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

Tcl

load ./chilkat.dll

set success 0

set mime [new_CkMime]

set success [CkMime_SetBodyFromPlainText $mime "Message with a Date header."]
if {$success == 0} then {
    puts [CkMime_lastErrorText $mime]
    delete_CkMime $mime
    exit
}

#  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
set now [CkMime_currentDateTime $mime]
puts "Current date/time: $now"

#  It can be used to populate a Date header field.
CkMime_SetHeaderField $mime "Date" $now

set head [CkMime_getEntireHead $mime]
if {[CkMime_get_LastMethodSuccess $mime] == 0} then {
    puts [CkMime_lastErrorText $mime]
    delete_CkMime $mime
    exit
}

puts "$head"

delete_CkMime $mime