B4X
B4X
Append MIME and Set the IMAP Internal Date
See more IMAP Examples
Demonstrates the Chilkat Imap.AppendMimeWithDateStr method, which uploads a MIME message while explicitly setting the server-side internal date. The first argument is the mailbox, the second is the MIME text, and the third is an RFC 822 date/time string (for example Fri, 10 Jul 2026 20:15:30 GMT). This example uploads to Archive with a specific internal date.
Background: The IMAP internal date is mailbox metadata, distinct from the message's own
Date header. It is normally the time the message arrived, and it is what the server uses for SINCE and BEFORE date searches. Setting it explicitly matters when migrating or importing messages, so imported mail keeps its original chronology instead of all appearing to arrive at import time.Chilkat B4X Downloads
Dim success As Boolean = False
' Demonstrates the Imap.AppendMimeWithDateStr method, which uploads a MIME message and sets
' its server-side internal date. The 1st argument is the mailbox, the 2nd is the MIME text,
' and the 3rd is an RFC 822 date/time string for the internal date.
Dim imap As ChilkatImap
imap.Initialize("imap")
imap.Ssl = True
imap.Port = 993
success = imap.Connect("imap.example.com")
If success = False Then
Log(imap.LastErrorText)
Return
End If
success = imap.Login("user@example.com", "myPassword")
If success = False Then
Log(imap.LastErrorText)
Return
End If
' Build the email to be uploaded.
Dim email As ChilkatEmail
email.Initialize
email.Subject = "Meeting agenda"
email.From = "Alice <alice@example.com>"
success = email.AddTo("Bob", "bob@example.com")
email.Body = "Let's meet at 10am to review the agenda."
Dim mimeText As String = email.GetMime
If email.LastMethodSuccess = False Then
Log(email.LastErrorText)
Return
End If
' Upload to "Archive" with an explicit internal date.
Dim internalDate As String = "Fri, 10 Jul 2026 20:15:30 GMT"
success = imap.AppendMimeWithDateStr("Archive", mimeText, internalDate)
If success = False Then
Log(imap.LastErrorText)
Return
End If
Log("Appended UID: " & imap.AppendUid)
success = imap.Disconnect
If success = False Then
Log(imap.LastErrorText)
Return
End If