Visual FoxPro
Visual FoxPro
Append MIME from a StringBuilder with Flags
See more IMAP Examples
Demonstrates the Chilkat Imap.AppendMimeWithFlagsSb method, which uploads MIME contained in a StringBuilder and sets its initial system flags. The first argument is the mailbox, the second is the StringBuilder, and the third through sixth set \Seen, \Flagged, \Answered, and \Draft. This example uploads to Drafts with the draft flag set.
Background: This is the
StringBuilder form of AppendMimeWithFlags. Passing the MIME as a StringBuilder avoids copying a large message into an intermediate string and is convenient when you already built or loaded the message into a StringBuilder (for example with LoadFile).Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loImap
LOCAL loEmail
LOCAL lcMimeText
LOCAL loSbMime
LOCAL lnSeen
LOCAL lnFlagged
LOCAL lnAnswered
LOCAL lnDraft
lnSuccess = 0
* Demonstrates the Imap.AppendMimeWithFlagsSb method, which uploads MIME contained in a
* StringBuilder and sets its initial system flags. The 1st argument is the mailbox, the 2nd
* is the StringBuilder, and the 3rd through 6th set \Seen, \Flagged, \Answered, and \Draft.
loImap = CreateObject('Chilkat.Imap')
loImap.Ssl = 1
loImap.Port = 993
lnSuccess = loImap.Connect("imap.example.com")
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
lnSuccess = loImap.Login("user@example.com","myPassword")
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
* Build the email to be uploaded.
loEmail = CreateObject('Chilkat.Email')
loEmail.Subject = "Meeting agenda"
loEmail.From = "Alice <alice@example.com>"
lnSuccess = loEmail.AddTo("Bob","bob@example.com")
loEmail.Body = "Let's meet at 10am to review the agenda."
lcMimeText = loEmail.GetMime()
IF (loEmail.LastMethodSuccess = 0) THEN
? loEmail.LastErrorText
RELEASE loImap
RELEASE loEmail
CANCEL
ENDIF
* Load the MIME into a StringBuilder. (A StringBuilder can also be filled via LoadFile.)
loSbMime = CreateObject('Chilkat.StringBuilder')
loSbMime.Append(lcMimeText)
* Choose the initial flags. Named variables make each argument's meaning clear at the call.
lnSeen = 0
lnFlagged = 0
lnAnswered = 0
lnDraft = 1
* Upload to "Drafts" with the \Draft flag set.
lnSuccess = loImap.AppendMimeWithFlagsSb("Drafts",loSbMime,lnSeen,lnFlagged,lnAnswered,lnDraft)
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
RELEASE loEmail
RELEASE loSbMime
CANCEL
ENDIF
? "Appended UID: " + STR(loImap.AppendUid)
lnSuccess = loImap.Disconnect()
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
RELEASE loEmail
RELEASE loSbMime
CANCEL
ENDIF
RELEASE loImap
RELEASE loEmail
RELEASE loSbMime