-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attachment shows as text in body of email #25
Comments
Do you have any text in the body of your message? E.g. do you have a template for What rails are you using? |
Rails 3.2. That was indeed the solution. Once I added html and text templates and a proper do format block in my call to mail(), it worked. Thanks |
@chrisgogreen ran into the same issue and i did have an html template for my mailer. I used this workaround: xlsx = render_to_string handlers: [:axlsx], formats: [:xlsx], template: "releases/order_report"
attachments["DailyOrderReport.xlsx"] = {mime_type: Mime::XLSX, content: xlsx}
self.instance_variable_set(:@_lookup_context, nil)
mail(to: recipients, subject: "Daily Order Report") |
@ph0t0n Which Rails version? |
@ph0t0n I think you need to pass a block to mail()like this: mail(:subject => "#{@Date} Status Report") do |format| Why don't you need a template? You could use an empty template, instance_variable_set smells fishy. |
@ph0t0n @chrisgogreen According to the ActionMailer documentation the block isn't required. So I'd like to isolate what is going on either way. I agree, I don't like having to reset the lookup context. It shouldn't be necessary. Recently Rails has started caching certain aspects of the rendering process to make things more efficient. I would not be surprised if it is related. @ph0t0n What Rails are you running? |
My complete version number is 3.2.19. Let me know what else I can check for you. |
Same thing happening on 3.2.18. Adding self.instance_variable_set(:@_lookup_context, nil) |
Same on Another solution?
The mail content will be taken from the |
@Roko131 Thanks for this result. That makes sense now why the first call to render to string is showing up in the message if your second render to string is producing the message. I'll have to dig into the lookup context to see what is going on sometime. |
Mail is going but in attachment, a sheet is not opening. My rails version: 4.2 My mailer action: and my action name and template name is different |
This is the email body:
This is my mailer:
This is the template 'status.xlsx.axlsx':
I can't see what I'm doing incorrectly.
The text was updated successfully, but these errors were encountered: