Visual FoxPro
Visual FoxPro
Add File Attachments to an Email
Demonstrates how to add one or more file attachments to an email.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loEmail
LOCAL lcContentType
lnSuccess = 0
loEmail = CreateObject('Chilkat.Email')
loEmail.Subject = "This is a test"
loEmail.Body = "This is a test"
loEmail.From = "support@chilkatsoft.com"
lnSuccess = loEmail.AddTo("Chilkat Admin","admin@chilkatsoft.com")
* To add file attachments to an email, call AddFileAttachment
* once for each file to be attached. The method returns
* the content-type of the attachment if successful, otherwise
* returns cknull
lcContentType = loEmail.AddFileAttachment("something.pdf")
IF (loEmail.LastMethodSuccess <> 1) THEN
? loEmail.LastErrorText
RELEASE loEmail
CANCEL
ENDIF
lcContentType = loEmail.AddFileAttachment("something.xml")
IF (loEmail.LastMethodSuccess <> 1) THEN
? loEmail.LastErrorText
RELEASE loEmail
CANCEL
ENDIF
lcContentType = loEmail.AddFileAttachment("something.zip")
IF (loEmail.LastMethodSuccess <> 1) THEN
? loEmail.LastErrorText
RELEASE loEmail
CANCEL
ENDIF
lnSuccess = loEmail.SaveEml("email.eml")
IF (lnSuccess = 0) THEN
? loEmail.LastErrorText
RELEASE loEmail
CANCEL
ENDIF
? "Saved EML!"
RELEASE loEmail