Sample code for 30+ languages & platforms
Visual Basic 6.0

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 Visual Basic 6.0 Downloads

Visual Basic 6.0
Dim success As Long
success = 0

'  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 New ChilkatImap

imap.Ssl = 1
imap.Port = 993

success = imap.Connect("imap.example.com")
If (success = 0) Then
    Debug.Print imap.LastErrorText
    Exit Sub
End If

success = imap.Login("user@example.com","myPassword")
If (success = 0) Then
    Debug.Print imap.LastErrorText
    Exit Sub
End If

'  Build the email to be uploaded.
Dim email As New ChilkatEmail
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
mimeText = email.GetMime()
If (email.LastMethodSuccess = 0) Then
    Debug.Print email.LastErrorText
    Exit Sub
End If

'  Upload to "Archive" with an explicit internal date.
Dim internalDate As String
internalDate = "Fri, 10 Jul 2026 20:15:30 GMT"
success = imap.AppendMimeWithDateStr("Archive",mimeText,internalDate)
If (success = 0) Then
    Debug.Print imap.LastErrorText
    Exit Sub
End If

Debug.Print "Appended UID: " & imap.AppendUid

success = imap.Disconnect()
If (success = 0) Then
    Debug.Print imap.LastErrorText
    Exit Sub
End If