Lianja
Lianja
Append a MIME Message to an IMAP Mailbox
See more IMAP Examples
Demonstrates the Chilkat Imap.AppendMime method, which uploads a complete RFC 822/MIME message to a mailbox. The first argument is the destination mailbox name and the second is the MIME text. This example obtains the MIME from an Email object and uploads it to Drafts.
Background: Use
AppendMime when you already hold a message's raw source — a .eml file, a message you assembled, or one you received. Chilkat sends the text exactly as supplied, without normalizing line endings or re-encoding headers, so every header and MIME boundary is preserved verbatim. The supplied text must be plain text (no raw non-text binary bytes).Chilkat Lianja Downloads
llSuccess = .F.
// Demonstrates the Imap.AppendMime method, which uploads a complete MIME message to a mailbox.
// The 1st argument is the destination mailbox name and the 2nd is the MIME text.
loImap = createobject("CkImap")
loImap.Ssl = .T.
loImap.Port = 993
llSuccess = loImap.Connect("imap.example.com")
if (llSuccess = .F.) then
? loImap.LastErrorText
release loImap
return
endif
llSuccess = loImap.Login("user@example.com","myPassword")
if (llSuccess = .F.) then
? loImap.LastErrorText
release loImap
return
endif
// Build the email to be uploaded.
loEmail = createobject("CkEmail")
loEmail.Subject = "Meeting agenda"
loEmail.From = "Alice <alice@example.com>"
llSuccess = loEmail.AddTo("Bob","bob@example.com")
loEmail.Body = "Let's meet at 10am to review the agenda."
// Obtain the MIME text to upload. Here it is generated from the Email, but it could equally
// be read from a .eml file.
lcMimeText = loEmail.GetMime()
if (loEmail.LastMethodSuccess = .F.) then
? loEmail.LastErrorText
release loImap
release loEmail
return
endif
// Append (upload) the MIME to the "Drafts" mailbox.
llSuccess = loImap.AppendMime("Drafts",lcMimeText)
if (llSuccess = .F.) then
? loImap.LastErrorText
release loImap
release loEmail
return
endif
? "Appended UID: " + str(loImap.AppendUid)
llSuccess = loImap.Disconnect()
if (llSuccess = .F.) then
? loImap.LastErrorText
release loImap
release loEmail
return
endif
release loImap
release loEmail