I am trying to create an email from a template, and then also attach a .csv file to my email, however the email only comes through with the attachment and the content is ignored? Any idea what I'm doing wrong here?
def send_email(csv_file, results) @subject = "subject here" @from = "hl7_data mailer<firstname.lastname@example.org>" @recipients = HL7_DATA_EMAIL_ADDRESS @results = results attachment :content_type => "text/csv", :body => csv_file end mailer_view/send_email.html.erb: Here is my content for the hl7 data email file: <%=@results%>
My file content used to display correctly but once I attached a file, it stopped displaying?
¿Alguna idea de por qué?
preguntado el 09 de marzo de 12 a las 23:03
To send attachments, you have to change the @content_type:
@content_type = "multipart/mixed"
This should then allow attachments.
So here is what I was looking for:
content = "here is my content" part :content_type => "text/plain", :charset => "us-ascii", :body => cont attachment :filename => 'invalid-records.csv', :disposition => "attachment", :content_type => "text/csv", :body => csv_file
So basically, I coulndt use the existing view file, I had to create inline content: