1

I have problem in attaching a file as an option in Pony and Sinatra, how can I specify attachment options in Pony?

user229044
  • 232,980
  • 40
  • 330
  • 338
sillyfem
  • 11
  • 2

1 Answers1

2

You just pass a hash of filenames => contents:

Pony.mail(
  :to => 'recipient@example.com',
  :subject => "My Subject",
  :body => "My Body",
  :attachments => {
    'CompanyReport.xls' => country_report_data
  }
)

Now country_report_data should be a String, possibly with binary. If you wrote to a tempfile, you could do:

country_report_data = File.read('/tmp/1029102938123', :binmode => true)
Seamus Abshere
  • 8,326
  • 4
  • 44
  • 61