views:

32

answers:

1

The content in the view is not being displayed. Only the attachment is being sent. Help would be appreciated!

def send
 @subject = "Status of PIS App"
 @recipients = "[email protected]"
 @from = APP_CONFIG[:email]
 @sent_on = Time.now
 #@content_type = "text/html"
 content_type = "multipart/alternative"

 attachment :filename => "Report.html",:content_type => "text/html",
  :body => File.read("/home/shreyas/repos/mysorepoc/app/models/new1.html")
end
+1  A: 

When using attachments, you need to specify the text part separately:

def send
  @subject = "Status of PIS App"
  @recipients = "[email protected]"
  @from = APP_CONFIG[:email]
  @sent_on = Time.now
  #@content_type = "text/html"
  content_type = "multipart/mixed"

  part :content_type => "text/plain", :body => "contents of body"

  attachment :filename => "Report.html",:content_type => "text/html", :body => File.read("/home/shreyas/repos/mysorepoc/app/models/new1.html")
end

And you probably want to send the mail as a multipart/mixed, not as multipart/alternative (unless the attachment really is an alternative representation of the text part).

Flurin Egger