# Passing array to the email body using ActionMailer

**URL:** <https://www.ruby-forum.com/t/passing-array-to-the-email-body-using-actionmailer/143389>\
**Category:** Rails\
**Created:** [July 17, 2008, 11:36pm UTC](https://www.ruby-forum.com/t/passing-array-to-the-email-body-using-actionmailer/143389 "2008-07-17T23:36:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cobra050](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3d9bf3/32.png) [@cobra050](https://www.ruby-forum.com/u/cobra050)\
**Post date:** [July 17, 2008, 11:36pm UTC](https://www.ruby-forum.com/t/passing-array-to-the-email-body-using-actionmailer/143389/1 "2008-07-17T23:36:06Z")

</div>

Hi, all

I am new to actionmailer. I am writing a script that sends emails  
contains lots of file names.

So the email will look like:

hi,

filename1  
filename2  
filename3  
.  
.  
.  
filenameN

So I want to pass an array containing all the filenames into the email  
body.

My code is below:

class Notifier \< ActionMailer::Base  
def log\_report(recipient, files)  
from ‘removed\_email\_address@domain.invalid’  
recipients recipient  
subject ‘Ruby automation scripts report’  
body ("Errors are detected in the following log files.

Here’s the log file:

#{files}")  
end  
end

When I run the code, I receive email with all the filenames in one line.  
However, I would like to have these filenames written one each line.

Is there way to format the email body?

Thanks

---

<div class="post-metadata">

**Author:** ![cobra050](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3d9bf3/32.png) [@cobra050](https://www.ruby-forum.com/u/cobra050)\
**Post date:** [July 18, 2008, 4:03am UTC](https://www.ruby-forum.com/t/passing-array-to-the-email-body-using-actionmailer/143389/2 "2008-07-18T04:03:56Z")

</div>

Try changing:

#{files}

To:

#{files.join("\n")}

HTH,

-Roy

---

<div class="post-metadata">

**Author:** ![cobra050](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/3d9bf3/32.png) [@cobra050](https://www.ruby-forum.com/u/cobra050)\
**Post date:** [July 18, 2008, 6:21pm UTC](https://www.ruby-forum.com/t/passing-array-to-the-email-body-using-actionmailer/143389/3 "2008-07-18T18:21:03Z")

</div>

Roy P. wrote:

> Try changing:
> 
> #{files}
> 
> To:
> 
> #{files.join("\n")}
> 
> HTH,
> 
> -Roy

Thanks Roy. It worked very well!!
