Sample code for 30+ languages & platforms
B4X 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 B4X Downloads

B4X
Dim success As Boolean = False

'  Assumes Chilkat is unlocked. See Global Unlock Sample.

Dim email As ChilkatEmail
email.Initialize
success = email.LoadEml("message.eml")
If success <> True Then
    Log(email.LastErrorText)
    Return
End If

Log("Previous Date: " & email.EmailDateStr)
Dim now As ChilkatDateTime
now.Initialize
success = now.SetFromCurrentSystemTime
If success <> True Then
    Log("Failed: now.SetFromCurrentSystemTime.")
    Return
End If

success = email.SetDt(now)
If success <> True Then
    Log(email.LastErrorText)
    Return
End If

Log("Updated Date: " & email.EmailDateStr)

success = email.SaveEml("updated-draft.eml")
If success <> True Then
    Log(email.LastErrorText)
    Return
End If

Log("Saved updated-draft.eml.")