# Specify email attachment name in code

**URL:** <https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708>\
**Category:** Kinetic ERP\
**Tags:** customization, reports, bpm, ssrs\
**Created:** [June 12, 2024, 5:49pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708 "2024-06-12T17:49:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@Andrew](https://www.epiusers.help/u/Andrew)\
**Post date:** [June 12, 2024, 5:49pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/1 "2024-06-12T17:49:21Z")

</div>

Has anyone specified an email attachment name via code?

I’m sending an Epicor standard report (several customized styles) to our customers based on criteria - A number of email address and recipient decisions must be made, therefore I’m executing the logic in a function which then sends the reports via email.

If I were using APR, I could set the attachment file name for each Style (and include helpful info). However, since I’m doing this all within code, I can’t seem to find the appropriate parameter to set.

For context, I’m setting the parameters in the Report’s parameter row:

![image](https://www.epiusers.help/uploads/default/original/3X/f/f/ff36eee0066f7114e32bb005dca68e38cca4ca5d.png)

I’m using FaxSubject for email subject:

![image](https://www.epiusers.help/uploads/default/original/3X/2/4/24910e1d92e986f99816d02f7e9f5eb44b62e7c7.png)

Any thoughts?

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [June 12, 2024, 5:53pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/2 "2024-06-12T17:53:11Z")

</div>

I’m pretty sure @klincecum has put code up where he’s doing this or it was someone else here. It’s on here somewhere.

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 12, 2024, 5:54pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/3 "2024-06-12T17:54:31Z")

</div>

un momento

Multiple Kevin’s have cracked this nut.

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [June 12, 2024, 5:54pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/4 "2024-06-12T17:54:48Z")

</div>

@klincecum this was not a tag to get you to provide/work on figuring out the code either, not a lazy tag.

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 12, 2024, 5:55pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/5 "2024-06-12T17:55:56Z")

</div>

I crave distractions.

* * *

* * *

* * *

and chicken :delicious:

---

<div class="post-metadata">

**Author:** ![Andrew](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@Andrew](https://www.epiusers.help/u/Andrew)\
**Post date:** [June 12, 2024, 5:58pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/6 "2024-06-12T17:58:28Z")

</div>

I felt pretty sure someone would have done this, but multiple searches returned APR and other (non-workable) options.

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 12, 2024, 5:59pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/7 "2024-06-12T17:59:29Z")

</div>

Before I answer, are you providing the chicken, or Utah? :delicious:

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [June 12, 2024, 5:59pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/8 "2024-06-12T17:59:34Z")

</div>

It most certainly is in the submit to agent step if I am not mistaken, whether someone did this with their own call or they did this in a BPM step I can’t recall.

---

<div class="post-metadata">

**Author:** ![utaylor](https://www.epiusers.help/user_avatar/www.epiusers.help/utaylor/32/64664_2.png) [@utaylor](https://www.epiusers.help/u/utaylor)\
**Post date:** [June 12, 2024, 5:59pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/9 "2024-06-12T17:59:49Z")

</div>

Dude haha I am not asking for this solution! But I like chicken too so I’ll bring it the next time.

---

<div class="post-metadata">

**Author:** ![Andrew](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@Andrew](https://www.epiusers.help/u/Andrew)\
**Post date:** [June 12, 2024, 6:00pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/10 "2024-06-12T18:00:41Z")

</div>

Yes. Utah is providing the chicken!  
(Utah, I’ll reimburse!)

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 12, 2024, 6:01pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/11 "2024-06-12T18:01:02Z")

</div>

Here is my function, does everything you want.

Let me read it and understand what I did, and I can explain your exact answer.

[https://www.epiusers.help/t/lets-share-useful-functions-sharing-is-caring/100371/2?u=klincecum](https://www.epiusers.help/t/lets-share-useful-functions-sharing-is-caring/100371/2)

---

<div class="post-metadata">

**Author:** ![gpayne](https://www.epiusers.help/user_avatar/www.epiusers.help/gpayne/32/55751_2.png) [@gpayne](https://www.epiusers.help/u/gpayne)\
**Post date:** [June 12, 2024, 6:01pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/12 "2024-06-12T18:01:11Z")

</div>

will this do what you want?

[https://www.epiusers.help/t/lets-share-useful-functions-sharing-is-caring/100371/46](https://www.epiusers.help/t/lets-share-useful-functions-sharing-is-caring/100371/46)

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 12, 2024, 6:03pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/13 "2024-06-12T18:03:50Z")

</div>

Here is the relevant bit:

```cs
  Dictionary<string, Stream> attachmentsDictionaryStream = new Dictionary<string, Stream>();      
  Dictionary<string, byte[]> attachmentsDictionaryBytes = null;
  
  try { attachmentsDictionaryBytes = JsonConvert.DeserializeObject<Dictionary<string, byte[]>>(attachmentsDictionaryJson); } catch {}
  
  if(attachmentsDictionaryBytes != null)
  {
      foreach(var item in attachmentsDictionaryBytes)
      {
          attachmentsDictionaryStream.Add(item.Key, new MemoryStream(item.Value));
      }
  }
  
  if(attachmentsDictionaryStream.Count() > 0)
  {
      mailer.Send(email, attachmentsDictionaryStream);
  }
  else mailer.Send(email);

```

---

<div class="post-metadata">

**Author:** ![Andrew](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@Andrew](https://www.epiusers.help/u/Andrew)\
**Post date:** [June 12, 2024, 6:09pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/14 "2024-06-12T18:09:10Z")

</div>

Uh… it _looks_ like the answer. It’s a bit more (real) coding that I typically do in Epicor, but I guess it’s time to broaden the ole horizons. I will dust off my reference books, grab some chicken, and see if I can digest (_Lol!_) this. Thank you!

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 12, 2024, 6:11pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/15 "2024-06-12T18:11:33Z")

</div>

If you want to modify your code to see how to fit it in, I don’t mind helping.

Or you could just use my library, or @kve has one similar.

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 12, 2024, 6:13pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/16 "2024-06-12T18:13:52Z")

</div>

Oh, I re-read the top post, and now I see what you are _actually_ doing.

Hmmmm, new thoughts are forming.

---

<div class="post-metadata">

**Author:** ![Andrew](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@Andrew](https://www.epiusers.help/u/Andrew)\
**Post date:** [June 12, 2024, 6:16pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/17 "2024-06-12T18:16:58Z")

</div>

![image](https://www.epiusers.help/uploads/default/original/3X/d/d/dd0278b06b996863c3b33fb58db79ec4996f37c8.png)

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 12, 2024, 6:19pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/18 "2024-06-12T18:19:18Z")

</div>

Does it have a description field? That’s probably where the file name comes from.

---

<div class="post-metadata">

**Author:** ![Andrew](https://www.epiusers.help/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@Andrew](https://www.epiusers.help/u/Andrew)\
**Post date:** [June 12, 2024, 6:24pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/19 "2024-06-12T18:24:00Z")

</div>

Looking at the parameters in API Help, I see no description field.

 ![image](https://www.epiusers.help/uploads/default/original/3X/7/1/71d7a9df13aa5cfbef486ab2f65bed6d73c7e90a.png)

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 12, 2024, 6:25pm UTC](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708/20 "2024-06-12T18:25:47Z")

</div>

Poking it.

I will say, if we can’t finagle the submit to agent call, I can show you how to use RunDirect to grab the report and do it the hard way. (It’s not that hard.)

[Next page](https://www.epiusers.help/t/specify-email-attachment-name-in-code/115708.md?page=2)
