Attachment File Archiving

You can archive email attachment files. You control whether email attachment files are archived by specifying one of the following Attachment Archive options: 

  1. AttachAndDoNotArchive which attaches the file to the email but does not archive it.
  2. AttachAndArchive which attaches the file to the email and archives it.
  3. ArchiveAndDoNotAttach which archives the file but does not attach it to the email. This option is useful if the attachment file is too large to include as an attachment. Instead, the email body can include the URL or Weblink to the archived attachment file.

If you choose to archive email attachment files, each email attachment file is written to a file just before the email is sent.

Attachment Archive Provider

Normally, the attachment file is archived to your authentication provider. For example, if your authentication provider is Google, the attachment file is archived to Google drive. If your authentication provider is Dropbox, the attachment file is archived to Dropbox.

If Smartsheet is your authentication provider, we archive the attachment file to Google drive. We do this because Smartsheet does not have a file system. If you use Smartsheet and wish to archive attachment files, you must include Google as a data provider. If Google is not already a data provider, you must go to Account>Data Sources and add Google as a data provider.

Attachment Folder Path

You can specify the Attachment Folder Path in the workflow action.

If you do not specify the Attachment Folder Path, then the default Attachment Folder Path value "Attachments" is used.

You can specify a constant Attachment Folder Path. For example: 

MyAttachments/MyPurchaseOrders

You can include expressions in the Attachment Folder Path. For example:

<<CONCATENATE("MyAttachments/PurchaseOrdersByMonth_", YEAR(NOW()), "_", MONTH(NOW()))>>

This might yield: 

MyAttachments/PurchaseOrdersByMonth_2019_02

As a result, each month's Email attachment files would reside in a separate folder.

Attachment Name

Attachment Name is described in topic "Attachment Name" here.

Disable Timestamp

By default, AppSheet includes a system generated Timestamp in the attachment file name. The Timestamp  contains the date and time at which the attachment file was created. The date and time are formatted as "yyyyMMdd_HHmmss_fff" where "fff" is milliseconds. This ensures the attachment file name is unique. For example:

MyAttachmentName20190207_133355_804.pdf

You can omit the Timestamp by setting the Disable Timestamp? option to On in the workflow action. 

If you disable the timestamp, you must ensure that every attachment file name is unique. If you fail to do this, one attachment file may overwrite another. For example, if you are archiving your attachment files to Google Drive, only the most recent attachment file will be present. Earlier attachment files with the same name will be overwritten.

Archive File Name

The Archive File Name is formed by combining the Attachment Name specified in the workflow action, with the optional Timestamp, and the file extension, such as .pdf, .json or .xml.

If your Attachment Name is "MyAttachmentName" and Disable Timestamp? is disabled, then your Archive File Name would be something like:

MyAttachmentName20190207_133355_804.pdf

If your Attachment Name is "MyAttachmentName" and Disable Timestamp? is enabled, then your Archive File Name would be:

MyAttachmentName.pdf

Archive Folder Name

You can control the Folder Name in which the archived attachment file is written using the Default app folder property and the Attachment Folder Path specified in the workflow action.  

The folder name is formed by combining the Default app folder property in the Info > Property pane with the Attachment Folder Path specified in the workflow action. If no Attachment Folder Path is specified in the workflow action, then the default Attachment Folder Path value "Attachments" is used.

If the Default app folder is "/1track/data/MyApp-24403", and the Attachment Folder Path is not specified, then the archive folder name is:

/1track/data/MyApp-24403/Attachments

If the Default app folder is "/1track/data/MyApp-24403/MyDefnFolder1", and the Attachment Folder Path is "MyFolderA/MyFolderZ", then the archive folder name is:

/1track/data/MyApp-24403/MyDefnFolder1/MyFolderA/MyFolderZ

Archive File and Folder Name

The complete archive file and folder name is formed by combining the Archive Folder Name with the Archive File Name.

For example, if the Archive Folder Name is "/1track/data/MyApp-24403/Attachments" and the Archive File Name is "ChangeReport20190207_133355_804.pdf", then the archive file and folder name is: 

/1track/data/MyApp-24403/Attachments/ChangeReport20190207_133355_804.pdf

If the Archive Folder Name is "/1track/data/MyApp-24403/MyAttachments/PurchaseOrdersByMonth_2019_02" and the Archive File Name is "PurchaseOrder20190207_133355_804.pdf", then the archive file and folder name is: 

/1track/data/MyApp-24403/MyAttachments/PurchaseOrdersByMonth_2019_02/PurchaseOrder20190207_133355_804.pdf

Archive File and Folder Name in Audit History

The archive file and folder name is displayed in Audit History. You can view it by:

  1. Opening the Audit History as described in this article 
  2. Locating the workflow entry in Audit History.
  3. Looking for the following data in the Audit History entry "EmailAttachment": "Name: 'ScheduledReport.pdf' Archive: AttachAndArchive FileName: 'Workflow-24403/Attachments/ScheduledReport20190201_184450_854.pdf'",
  4. The "FileName" value indicates the file and folder where the attachment was archived.

Expression Variables for Attachment Archiving

The attachment file name is available for use in your workflow templates in the built-in variable _ATTACHMENTFILENAME. You can include this variable in your email Body or Attachment template to display the name of the archived attachment file.

The attachment file URL is available for use in your workflow templates in the built-in variable _ATTACHMENTFILE_URL. You can include this variable in your email Body or Attachment template to display the URL of the archived attachment file.

The attachment file hyperlink is available for use in your workflow templates in the built-in variable _ATTACHMENTFILE_WEB_LINK. You can include this variable in your email Body or Attachment template to display a hyperlink to the archived attachment file. The Attachment Name is displayed as the hyperlink text.

Constructing an Attachment File URL

Attachment file URLs take the form:

https://www.appsheet.com/template/getappfileurl?appName=<YourAppName>&fileName=<YourAttachmentFileName>

<YourAttachmentFileName> must specify the Attachment Folder Name followed by the Archive File Name. Omit the Default app folder name. Calls to "www.appsheet.com/template/getappfileurl" automatically prepend the Default app folder name.

The values <YourAppName> and <YourAttachmentFileName> must be URL encoded if them contain "reserved" or "unsafe" URL characters. For example, if <YourAppName> is "MyOrderApp-432567" and <YourAttachmentFileName> is "MyAttachments/MyPdfReport.pdf", then the URL is:

https://www.appsheet.com/template/getappfileurl?appName=MyOrderApp-432567&fileName=MyAttachments%2FMyPdfReport.pdf

In this example, the slash ("/") in the Attachment Name is URL encoded as "%2F".

Did this answer your question?