¿Por qué mi correo electrónico no tiene contenido en Rails 2.2 y solo tiene un archivo adjunto?

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<hl7-data@email.com>"
    @recipients = HL7_DATA_EMAIL_ADDRESS
    @results = results
    attachment :content_type => "text/csv", :body => csv_file

    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

2 Respuestas

To send attachments, you have to change the @content_type:

@content_type = "multipart/mixed"

This should then allow attachments.

respondido 10 mar '12, 17:03

This is the default content_type when you add an attachment. - kamilski81

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: mailer_view/send_email.html.erb

respondido 12 mar '12, 15:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.