Andrew Libby on 20 Jun 2008 09:13:04 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PhillyOnRails] ActiveMailer issue sending email with both attachment AND body content


Try setting your content_type  to  "multipart/alternative"

Andy


Ryan Miller wrote:
Sure, thanks for your reply.  You'll see in my model the two ways I've
tried attaching the file.  Both work, but both also remove my content
(view).

=========== controller ==============
class InfoController < ApplicationController
  protect_from_forgery :only => [:create, :delete, :update]
def index
  	Info.deliver_test_email(params, request.env)

  	redirect_to request.env["HTTP_REFERER"]
  end
end
=========== end controller ===============

=========== model ===================
class Info < ActionMailer::Base

  def test_email(params, request)
    sent_on     Time.new
    subject     'Information request from website'
    recipients  params[:txtEmail]
from 'miller2300@comcast.net' content_type 'text/html'

    attachment :content_type => "image/jpeg",
       :body => File.read("/tmp/CGI.5798.6")
body(:sent_on => sent_on,:first_name =>
params[:txtFirstName], :last_name => params[:txtLastName], :address =>
params[:txtEmail])
#attachment "image/jpeg" do |a|
    #	a.filename="boris.jpg"
    #	a.body = File.read("/tmp/CGI.5654.4")
    #end
  end
end
============ end model ==============
============ view =============
<h3>Web form request at <%= @sent_on %></h3>

<p>From: <em><%= @first_name %> <%= @last_name %> (<%= @address %>)</em>
</p>
=========== end view ===========



-------- Forwarded Message --------
From: Andrew Libby <alibby@tangeis.com>
Reply-To: talk@phillyonrails.org
To: talk@phillyonrails.org
Subject: Re: [PhillyOnRails] ActiveMailer issue sending email with
both	attachment AND body content
Date: Thu, 19 Jun 2008 09:37:41 -0400

Mind posting your mailer code?

This might help us figure out what's going on.



Thanks.

Ryan Miller wrote:
I'm having some issues with a simple form mailer using ActiveMailer in rails
2.0.2.

I can send a plain old regular email just fine.
I can send an email with an attachment just fine.

But, when I try to send an email with body content AND an attachment, the
email gets sent and delivered with the attachment, but the body content is
completely empty.  I've tried so many different things, but just can't get
it to work.
Anyone seen this before or suggest something to try?  Many thanks in
advance.


// Ryan Miller
/*  Vive il sogno, via come il vento! */

_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk


_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk

--

===============================================
Tangeis, LLC
Andrew Libby
alibby@tangeis.com
www.tangeis.com
610-761-1991
===============================================


_______________________________________________
To unsubscribe or change your settings, visit:
http://lists.phillyonrails.org/mailman/listinfo/talk