Visual FoxPro
Visual FoxPro
Change the Filename of an Attachment
See more Email Object Examples
Demonstrates the Chilkat Email.SetAttachmentFilename method, which changes the filename of the attachment at a given zero-based index. This example adds an attachment and renames it, printing the filename before and after.
Background: The attachment filename is what a recipient sees and what most clients suggest when saving the file. Renaming it is handy when the original name is unclear, unsafe, or generic — for example giving a machine-generated
tmp12345 a meaningful name like invoice.pdf before sending.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loEmail
lnSuccess = 0
* Demonstrates the SetAttachmentFilename method, which changes the filename of the
* attachment at the given zero-based index.
loEmail = CreateObject('Chilkat.Email')
loEmail.Subject = "Set attachment filename"
loEmail.AddStringAttachment("oldname.txt","Some notes.")
? "Filename before: " + loEmail.GetAttachmentFilename(0)
* Change the filename of the first attachment (index 0).
lnSuccess = loEmail.SetAttachmentFilename(0,"newname.txt")
IF (lnSuccess = 0) THEN
? loEmail.LastErrorText
RELEASE loEmail
CANCEL
ENDIF
? "Filename after: " + loEmail.GetAttachmentFilename(0)
RELEASE loEmail