Sample code for 30+ languages & platforms
AutoIt Requires Chilkat v11.0.0+

Update the Date of a saved draft

See more Email Object Examples

New Email objects already have a Date field. When reusing a saved draft, set its Date from the system clock immediately before submission. Save a separate copy so the original date is still available.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

;  Assumes Chilkat is unlocked. See Global Unlock Sample.

$oEmail = ObjCreate("Chilkat.Email")
$bSuccess = $oEmail.LoadEml("message.eml")
If ($bSuccess <> True) Then
    ConsoleWrite($oEmail.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite("Previous Date: " & $oEmail.EmailDateStr & @CRLF)
$oNow = ObjCreate("Chilkat.CkDateTime")
$bSuccess = $oNow.SetFromCurrentSystemTime()
If ($bSuccess <> True) Then
    ConsoleWrite("Failed: now.SetFromCurrentSystemTime." & @CRLF)
    Exit
EndIf

$bSuccess = $oEmail.SetDt($oNow)
If ($bSuccess <> True) Then
    ConsoleWrite($oEmail.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite("Updated Date: " & $oEmail.EmailDateStr & @CRLF)

$bSuccess = $oEmail.SaveEml("updated-draft.eml")
If ($bSuccess <> True) Then
    ConsoleWrite($oEmail.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite("Saved updated-draft.eml." & @CRLF)