Xbase++
Xbase++
Save Email Attachments to Filesystem
Saves email attachments to a directory.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oEmail
LOCAL i
nSuccess := 0
oEmail := CreateObject("Chilkat.Email")
// Load an email object containing attachments.
// This .eml can be downloaded from:
// http://www.example-code.com/testData/HtmlEmail.eml
nSuccess := oEmail:LoadEml("HtmlEmail.eml")
IF (nSuccess != 1)
? oEmail:LastErrorText
oEmail:destroy()
RETURN
ENDIF
// If OverwriteExisting is turned on, files with the same
// name are overwritten. If turned off, new/unique filenames
// are automatically generated. The filenames actually saved
// are accessible via the GetAttachmentFilename method.
oEmail:OverwriteExisting := 1
// Save all attachments to the "myAttachments" subdirectory
// found under the calling process's current working directory.
// This directory is automatically created if it does not already
// exist.
nSuccess := oEmail:SaveAllAttachments("myAttachments")
IF (nSuccess != 1)
? oEmail:LastErrorText
oEmail:destroy()
RETURN
ENDIF
// List the attachment filenames:
FOR i := 0 TO oEmail:NumAttachments - 1
? oEmail:GetAttachmentFilename(i)
NEXT
oEmail:destroy()