AddMailAttachment

<< Click to Display Table of Contents >>

Navigation:  E-Mail Functions >

AddMailAttachment

Previous pageReturn to chapter overviewNext page

[Windows platform only; not supported by the Community Edition]

Allows you to specify a list of e-mail attachments (files) by code.

method void VPE.AddMailAttachment(

String PathName,

String FileName

)

String PathName

The fully qualified path and file name of the attachment file. This path should include the disk drive letter and directory name. The attachment file should be closed before this call is made.

 

When MailDoc() is called, VPE will examine all attachment paths. If the last character of a path is a backslash ("\"), VPE will write the current document as a temporary file to the specified path and add it as attachment to the mail.

If the examined path is NULL or empty (""), VPE will create and attach the temporary document in the temporary directory specified by the environment variable named TMP or TEMP, or - if both are not set - in the current working directory.

Any temporarily created file will be deleted before the MailDoc() method returns.

 

Otherwise - if a fully qualified path and file name was specified - VPE expects that the attachment file has already been created. This gives you the possibility to mail any kind of attachment, not being limited to VPE-Documents.

String FileName

The filename seen by the recipient. This name can differ from the filename in PathName if temporary files are being used. If FileName is NULL or empty (""), the filename from PathName is used. If the attachment is an OLE object, FileName contains the class name of the object, such as "Microsoft Excel Worksheet."

Remarks:

By default, the current document is automatically set as an attachment located in the tmp-dir (the file will only be created if - and in the moment when - MailDoc() is executed). The file name of the attachment is either the Application Name or  - if SwapFileName is set - the document file name. To clear that default, call ClearMailAttachments() before specifying your own attachments.

 

The property MailAutoAttachDocType controls, whether a VPE Document or a PDF Document is attached to the e-mail.

Examples:

Doc.ClearMailAttachments()

Deletes the default attachment, which is the VPE Document itself.

 

Doc.AddMailAttachment("c:\important_file.zip", "")

Sets "c:\important_file.zip" as the ONLY attachment. The VPE Document is not sent, because ClearMailAttachments() deleted the default attachment of the VPE Document.

 

Doc.AddMailAttachment("c:\important_file.txt", "")

Adds "c:\important_file.txt" as second attachment.

 

Doc.WriteDoc("c:\tmp\doc.vpe")

Doc.AddMailAttachment("c:\tmp\doc.vpe", "")

Adds "c:\tmp\doc.vpe" as third attachment.