Sample code for 30+ languages & platforms
Lua

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

Lua
local chilkat = require("chilkat")

local mime = chilkat.Mime.new()
local success = mime:set_body_from_plain_text("Message with a Date header.")
if not success then
    print(mime.last_error_text)
    return
end

-- 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
local now = mime.current_date_time
print("Current date/time: " .. now)

-- It can be used to populate a Date header field.
mime:set_header_field("Date", now)

local head = mime:get_entire_head()
if not mime.last_method_success then
    print(mime.last_error_text)
    return
end

print(head)