Newbie question - how to write an array to a file in the context so I can send with O365 email integration

Showing results for 
Show  only  | Search instead for 
Did you mean: 

Newbie question - how to write an array to a file in the context so I can send with O365 email integration

L1 Bithead

I have an array of hostnames, which I want to then turn into an attachment and then send by email using the O365 integration.

If I put ${array} into the body, it will loop and send an email for each element of the array. If I do ArrayToCSV, it then just sends a comma separated line of host names.


What I really want to do is create a file with a header (hostname) and then a line for each host name in the array, which I can then use as an attachment Id in the O365 integration, and I'm struggling. Are there any automations that I can use to do this?



L5 Sessionator

Hi @bowesmana, you're going to have to split this into 2 steps. One to the make the file and the other to send it. Since you did not specify a format, I'll assume .txt should work.


Screenshot 2024-06-07 at 2.38.46 PM.png 

1. You can use the FileCreateAndUpload function. This will return a file object to the warroom. You can then use this entryID to attach to the email. 

2. List created in content and references in "Get" section.

3. I've used ArrayToCSV, but you can use anything that merges your content. Join, append, stringfy, etc.

4. Since you wanted a title. 

5. Command output, file output below.

Screenshot 2024-06-07 at 2.42.57 PM.png

Thanks @jfernandes1 I ended up writing a short Python automation - in your solution it joins the rows into a single row, but I wanted the host on a new line, so I can effectively export that as a file that others can load into a some tool to view, it has around 10,000 entries so not useful on one line.

Appreciate the learning - thanks!

L5 Sessionator

Hi @bowesmana, in my previous example, you can swap the ArrayToCSV for the Join transformer. In the Join set the delimiter to the enter or return key. This will add each entry on a new line. 

Screenshot 2024-06-11 at 12.06.15 PM.png

  • 3 replies
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!