# Attaching File to Email Send using template message type

**URL:** <https://community.cdata.com/t/attaching-file-to-email-send-using-template-message-type/689>\
**Category:** CData Arc\
**Tags:** question, email-send, cdata-arc\
**Created:** [April 9, 2024, 12:21pm UTC](https://community.cdata.com/t/attaching-file-to-email-send-using-template-message-type/689 "2024-04-09T12:21:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ericbux](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/ericbux/32/1679_2.png) [@ericbux](https://community.cdata.com/u/ericbux)\
**Post date:** [April 9, 2024, 12:21pm UTC](https://community.cdata.com/t/attaching-file-to-email-send-using-template-message-type/689/1 "2024-04-09T12:21:46Z")

</div>

In my main application, I started using Arc to send automated emails by writing a simple XML file to a folder that Arc monitors.&nbsp; I have a case where I am mapping the XML to an Email Send connector (using template mode) and I need to attach a PDF to the message (which was already uploaded to the server).

I have the path to the file saved in SQL and I can add the path to my XML file.&nbsp; My question is, how can I configure the Email Send connector to “attached” the file (assuming the path is a node in my XML)?&nbsp; Right now, all I can do is reformat the path into an http link and add it to the body.

Thanks

---

<div class="post-metadata">

**Author:** ![lohith](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/lohith/32/1848_2.png) [@lohith](https://community.cdata.com/u/lohith)\
**Post date:** [April 11, 2024, 4:23am UTC](https://community.cdata.com/t/attaching-file-to-email-send-using-template-message-type/689/2 "2024-04-11T04:23:26Z")

</div>

Hi Eric,

If I understand correctly, you want to send attachments along with your email body. In the advanced section of our configuration, there’s an option that allows you to attach files.

 ![1502387f-4804-421c-bd3f-8407b2a31004.png](https://us1.discourse-cdn.com/cdata/original/2X/a/ad71068b6353e943cff6d6380068b3d1e76df879.png)

If you are using an earlier release, you may add&nbsp;this configuration under the “Other Settings” section.

```auto
allowarcscriptinattachmentmode = True

```

Please make sure to&nbsp;run the connector in attachment mode instead of template.

---

<div class="post-metadata">

**Author:** ![ericbux](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/ericbux/32/1679_2.png) [@ericbux](https://community.cdata.com/u/ericbux)\
**Post date:** [April 11, 2024, 1:14pm UTC](https://community.cdata.com/t/attaching-file-to-email-send-using-template-message-type/689/3 "2024-04-11T13:14:13Z")

</div>

Just to be clear, my Input document to the Email Send connector looks like this:

```xml
<Items> <Name>Joe Dirt</Name> <OrderNum>0032112</OrderNum> <Invoice>JD0246</Invoice> <File>JD0246.pdf</File></Items

```

If I use Attachment mode, Arc will attach the above XML file to the email.

I’m currently running&nbsp;2023 - 23.3.8725.0 and don’t see the above checkbox so I assume I will need to use the snip for “Other Settings”.

My question is:&nbsp; where does the ArcScript go to locate and attach the file in [xpath(File)] (I know where logical path to the file location)?&nbsp; Would I use the Before Send event?

 ![afefa8bc-df3f-4ab9-a5a6-cba19ff19ccd.png](https://us1.discourse-cdn.com/cdata/original/1X/0db4eecd40491ec10ba1afbe388381bbd4e8ebad.png)

Thanks

---

<div class="post-metadata">

**Author:** ![lohith](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/lohith/32/1848_2.png) [@lohith](https://community.cdata.com/u/lohith)\
**Post date:** [April 12, 2024, 3:42am UTC](https://community.cdata.com/t/attaching-file-to-email-send-using-template-message-type/689/4 "2024-04-12T03:42:52Z")

</div>

Hi Eric,

If you are using an earlier release, you will need to configure the settings under other settings.

In attachment mode, you can write the script within the settings tab of the connector, and the file passed through the input will be sent as an attachment.

Here is an example: I am sending the filename as the body of the email along with the attachment.

 ![4016d483-d4ae-47ad-8f2d-8ddafd54874f.png](https://us1.discourse-cdn.com/cdata/original/1X/cc5ce1e464da8f8f14acff4abfe6d86be7a0a12d.png)

Test email received:

 ![2f1ea153-b39c-4b64-b6ca-1a5661c0a3a2.png](https://us1.discourse-cdn.com/cdata/original/2X/6/6178a447738f66332c0c794a063e38c1144ee505.png)

---

<div class="post-metadata">

**Author:** ![James\_B](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/james_b/32/1688_2.png) [@James\_B](https://community.cdata.com/u/James_B)\
**Post date:** [April 12, 2024, 12:52pm UTC](https://community.cdata.com/t/attaching-file-to-email-send-using-template-message-type/689/5 "2024-04-12T12:52:18Z")

</div>

Hi Eric,

The EmailSend connector wouldn’t be the right one for this task as you present it now - you can evaluate the message as a template using the template mode, and attach the message file (in this case, the xml file), but you cannot dynamically evaluate additional attachments to the EmailSend connector.

If you had a flow that picked up and processed the PDF file itself, and sent that to the EmailSend connector in Attachment mode, that would send your PDF - and if you included all of the other metadata as headers on the messages in Arc, reversing your message structure:

> **[Message Headers - CData Arc - Architecture | Version 23.4.8839](https://cdn.cdata.com/help/AZJ/mft/Architecture.html#message-headers)**
>
> CData Arc is a message-driven platform for integrating business processes. It provides a centralized Communications Hub that enables applications, databases, and external messaging systems to talk to each other.

Then you could&nbsp;send your PDF in attachment mode, and use the&nbsp;allowarcscriptinattachmentmode as Lohith mentions to dynamically render those elements in the headers in the body:

 ![8ef94d35-facd-4c0d-9e16-2a70e5a19274.png](https://us1.discourse-cdn.com/cdata/original/2X/2/2306762fa81a1c45bbd710eb645f16f967802867.png)

If you do that, you could use a script to parse your XML and output the PDF referenced in it with additional headers. Assuming that you have these PDF’s in a static folder, something like this would work:

```xml
<!-- Parse the XML --><arc:set attr="xml.uri" value="[Filepath]" /><arc:set attr="xml.map:name" value="/Items/Name" /><arc:set attr="xml.map:ordernum" value="/Items/OrderNum" /><arc:set attr="xml.map:Invoice" value="/Items/Invoice" /><arc:set attr="xml.map:file" value="/Items/File" /><arc:call op="xmlDOMGet" item="xml"> <arc:set attr="output.header:name" value="[xml.name]" /> <arc:set attr="output.header:ordernum" value="[xml.ordernum]" /> <arc:set attr="output.header:Invoice" value="[xml.Invoice]" /> <arc:set attr="output.header:file" value="[xml.file]" /> <!-- Reference the filepath for output --> <arc:set attr="output.filepath" value="C:\\Users\\JamesBlasingame\\OneDrive - CData Software\\Documents\\[xml.file]" /></arc:call><arc:push item="output" />

```

Alternately, there is an operation that will send an email using the default email settings for notifications, appSendEmail:

> **[CData Arc - appSendEmail | Version 23.4.8839](https://cdn.cdata.com/help/AZJ/mft/op_appSendEmail.html)**

This supports attachment arguments, but it’s not as easy to review for errors as the appSendEmail operation.
