---
title: "attachFileFromEmail"
canonical: "https://support.appfire.com/space/PSJ/15481031/attachFileFromEmail"
format: markdown
---
> Macro (aura-html)


> 📝 The use of this function requires the Power Scripts for Jira add-on be installed and licensed.

|  |  |  |  |
| --- | --- | --- | --- |
| **Syntax** | attachFileFromEmail(attachmentName, issueKey) | **Package** |  |
| **Alias** |  | **Pkg Usage** |  |

## Description

> Macro (excerpt)
> 
> Attaches a single file from the incoming email to a specified issue.

Attaches a single file from the incoming email to a specified issue.

## Parameters

| Parameter name | Type | Required | Description |
| --- | --- | --- | --- |
| attachmentName | string | Yes | The name of the attachment from the incoming email. Note that if there are multiple attachments with the same name, this will always attach the first one in the list. |
| issueKey | string | Yes | The issue to attach the file to. |

## Return Type

**Boolean**

Returns "true" if file was successfully attached to issue and "false" otherwise.

## Example

```
IncomingEmail email = getIncomingEmail();
string issueKey = matchText(email.subject, "[A-Z][A-Z]+-[0-9]+"); // find an issue key in the subject
if(isNotNull(issueKey)) {
    for(string att in email.attachments) {
		// only attach PDFs
        if(endsWith(att, ".pdf")) {
            attachFileFromEmail(att, issueKey);
        }
    }
}
```

## See also

> Macro (contentbylabel)

> Macro (fc909b09-b512-4c31-a844-dd855b0e6aae/db1c8759-c7e5-4e80-9022-d19e47b0e2b0/static/macro)