Passing array to the email body using ActionMailer

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 ‘[email protected]
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

Try changing:

#{files}

To:

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

HTH,

-Roy

Roy P. wrote:

Try changing:

#{files}

To:

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

HTH,

-Roy

Thanks Roy. It worked very well!!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs