How to do the attachment in mail like the yahoo and gmail does? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
<% form_tag(depot_help_desk_path, :method => :post, :multipart => true) do %> <div> <fieldset> <legend>Helpdesk formulier</legend> <div style="width: 300 px;">1. Ik werk met de volgende browser:</ div> <%= radio_button "helpdesk", "browser", "Internet Explorer" %>Internet Explorer<br/> <%= radio_button "helpdesk", "browser", "Safari" %>Safari<br/> <%= radio_button "helpdesk", "browser", "Mozilla Firefox" %>Mozilla Firefox<br /><br /> <div style="width: 300 px;">2. Ik werk met de volgende computer:</ div> <%= radio_button "helpdesk", "os", "windows" %>Windows<br /> <%= radio_button "helpdesk", "os", "mac" %>Mac<br /> <%= radio_button "helpdesk", "os", "linux" %>Linux<br /><br /> <div style="width: 300 px;">3. Mijn gebruikersnaam is:</div> <label id="label_right"><%= text_field ''helpdesk'', ''user_name'', :class => "txtfield", :size => 20 %></label><br /><br /> <div style="width: 300 px;">4. Mijn e-mail adres is:</div> <label id="label_right"><%= text_field ''helpdesk'', ''email'', :class => "txtfield", :size => 20 %></label><br /><br /> <div style="width: 400 px;">5. Het probleem is op de volgende datum opgetreden:</div> <label id="label_right"><%= text_field ''helpdesk'', ''datum'', :class => "txtfield", :size => 20 %></label><br /><br /> <div style="width: 300 px;">6. De URL waar het probleem zich voordoet is:</div> <label id="label_right"><%= text_field ''helpdesk'', ''url'', :class => "txtfield", :size => 20 %></label><br /><br /> <div style="width: 300 px;">7. Bestand toevoegen:</div> <%= file_field ''helpdesk'', ''file'', :class => "txtfield", :size => 20 %><br /><br /> <div style="width: 300 px;">8. Het originele bestand heb ik bijgevoegd:</div> <%= radio_button "helpdesk", "bestand", "ja" %>ja<br /> <%= radio_button "helpdesk", "bestand", "nee" %>nee<br /><br /> <div style="width: 550 px;">9. Graag zo volledig mogelijk omschrijven (stapsgewijs) wat het probleem / je vraag is.</div> <label id="label_right"><%= text_area ''helpdesk'', ''text'', :cols => "70", :rows => 20 %></label><br /><br /> <div style="width: 550 px;">Hartelijk dank voor het invullen van bovenstaand formulier. Klik op versturen en wij streven ernaar binnen 5 werkdagen te reageren.</div> <div><%= submit_tag "versturen", :onClick => "", :id => ''disable- me'' %></div><br /> </fieldset> </div> <% end %> def ticket_with_attachment(browser, os, email, user_name, datum, url, file, bestand, text, sent_at = Time.now ) @subject = ''Helpdesk verzoek: '' + user_name @body = { :browser => browser, :os => os, :user_name => user_name, :email => email, :datum => datum, :url => url, :bestand => bestand, :text => text } @recipients = "xxx-fdLVfzN/7KE@public.gmane.org" @from = "xxx-fdLVfzN/7KE@public.gmane.org" @sent_on = sent_at unless file.blank? attachment :body => file.read, :filename => file.original_filename end end That''s working code from one of our apps. Not very nice looking, but should do. Important parts are the file_field in the form (all others are just text or radio buttons) and those lines in the ActionMailer delivery method: unless file.blank? attachment :body => file.read, :filename => file.original_filename end which will attach the file to the mail --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thank you Muller I will try it and let you know the oucome. On Jul 2, 1:49 pm, Thorsten Müller <thors...-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote:> <% form_tag(depot_help_desk_path, :method => :post, :multipart => > true) do %> > <div> > <fieldset> > <legend>Helpdesk formulier</legend> > <div style="width: 300 px;">1. Ik werk met de volgende browser:</ > div> > <%= radio_button "helpdesk", "browser", "Internet Explorer" > %>Internet Explorer<br/> > <%= radio_button "helpdesk", "browser", "Safari" %>Safari<br/> > <%= radio_button "helpdesk", "browser", "Mozilla Firefox" > %>Mozilla Firefox<br /><br /> > > <div style="width: 300 px;">2. Ik werk met de volgende computer:</ > div> > <%= radio_button "helpdesk", "os", "windows" %>Windows<br /> > <%= radio_button "helpdesk", "os", "mac" %>Mac<br /> > <%= radio_button "helpdesk", "os", "linux" %>Linux<br /><br /> > > <div style="width: 300 px;">3. Mijn gebruikersnaam is:</div> > <label id="label_right"><%= text_field ''helpdesk'', > ''user_name'', :class => "txtfield", :size => 20 %></label><br /><br /> > > <div style="width: 300 px;">4. Mijn e-mail adres is:</div> > <label id="label_right"><%= text_field ''helpdesk'', > ''email'', :class => "txtfield", :size => 20 %></label><br /><br /> > > <div style="width: 400 px;">5. Het probleem is op de volgende > datum opgetreden:</div> > <label id="label_right"><%= text_field ''helpdesk'', ''datum'', :class > => "txtfield", :size => 20 %></label><br /><br /> > > <div style="width: 300 px;">6. De URL waar het probleem zich > voordoet is:</div> > <label id="label_right"><%= text_field ''helpdesk'', ''url'', :class > => "txtfield", :size => 20 %></label><br /><br /> > > <div style="width: 300 px;">7. Bestand toevoegen:</div> > <%= file_field ''helpdesk'', ''file'', :class => "txtfield", :size => > 20 %><br /><br /> > > <div style="width: 300 px;">8. Het originele bestand heb ik > bijgevoegd:</div> > <%= radio_button "helpdesk", "bestand", "ja" %>ja<br /> > <%= radio_button "helpdesk", "bestand", "nee" %>nee<br /><br /> > > <div style="width: 550 px;">9. Graag zo volledig mogelijk > omschrijven (stapsgewijs) wat het probleem / je vraag is.</div> > <label id="label_right"><%= text_area ''helpdesk'', ''text'', :cols => > "70", :rows => 20 %></label><br /><br /> > > <div style="width: 550 px;">Hartelijk dank voor het invullen van > bovenstaand formulier. Klik op versturen en wij streven ernaar binnen > 5 werkdagen te reageren.</div> > > <div><%= submit_tag "versturen", :onClick => "", :id => ''disable- > me'' %></div><br /> > </fieldset> > </div> > <% end %> > > def ticket_with_attachment(browser, os, email, user_name, datum, > url, file, bestand, text, sent_at = Time.now ) > @subject = ''Helpdesk verzoek: '' + user_name > @body = { :browser => browser, :os => os, :user_name => > user_name, :email => email, :datum => datum, :url => url, :bestand => > bestand, :text => text } > @recipients = "x...-fdLVfzN/7KE@public.gmane.org" > @from = "x...-fdLVfzN/7KE@public.gmane.org" > @sent_on = sent_at > unless file.blank? > attachment :body => file.read, :filename => > file.original_filename > end > end > > That''s working code from one of our apps. Not very nice looking, but > should do. > Important parts are the file_field in the form (all others are just > text or radio buttons) > and those lines in the ActionMailer delivery method: > > unless file.blank? > attachment :body => file.read, :filename => file.original_filename > end > > which will attach the file to the mail--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I read your code and do something like this in my actionmailer class def contact(recipient, subject, message,user_id,attachment1=nil, sent_at = Time.now) @body[''user_id'']= user_id @subject = subject @recipients = recipient @from = ''noreply-hbU1m2TDgP9Wk0Htik3J/w@public.gmane.org'' @sent_on = sent_at @body["title"] = ''You have new Job Application'' @body["message"] = message unless attachment1.nil? attachment "application/octet-stream" do |a| a.body=attachment1.read a.filename=attachment1.original_filename end end attachment :content_type=>"image/jpeg", :body=>File.read("#{RAILS_ROOT}/public/images/ afterpinkslip.jpg"), :filename=>File.basename("#{RAILS_ROOT}/public/images/ afterpinkslip.jpg") end and it works beautifully. Thank you once again. On Jul 2, 2:25 pm, mrbless <mrbl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thank you Muller I will try it and let you know the oucome. > > On Jul 2, 1:49 pm, Thorsten Müller <thors...-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org> wrote: > > > <% form_tag(depot_help_desk_path, :method => :post, :multipart => > > true) do %> > > <div> > > <fieldset> > > <legend>Helpdesk formulier</legend> > > <div style="width: 300 px;">1. Ik werk met de volgende browser:</ > > div> > > <%= radio_button "helpdesk", "browser", "Internet Explorer" > > %>Internet Explorer<br/> > > <%= radio_button "helpdesk", "browser", "Safari" %>Safari<br/> > > <%= radio_button "helpdesk", "browser", "Mozilla Firefox" > > %>Mozilla Firefox<br /><br /> > > > <div style="width: 300 px;">2. Ik werk met de volgende computer:</ > > div> > > <%= radio_button "helpdesk", "os", "windows" %>Windows<br /> > > <%= radio_button "helpdesk", "os", "mac" %>Mac<br /> > > <%= radio_button "helpdesk", "os", "linux" %>Linux<br /><br /> > > > <div style="width: 300 px;">3. Mijn gebruikersnaam is:</div> > > <label id="label_right"><%= text_field ''helpdesk'', > > ''user_name'', :class => "txtfield", :size => 20 %></label><br /><br /> > > > <div style="width: 300 px;">4. Mijn e-mail adres is:</div> > > <label id="label_right"><%= text_field ''helpdesk'', > > ''email'', :class => "txtfield", :size => 20 %></label><br /><br /> > > > <div style="width: 400 px;">5. Het probleem is op de volgende > > datum opgetreden:</div> > > <label id="label_right"><%= text_field ''helpdesk'', ''datum'', :class > > => "txtfield", :size => 20 %></label><br /><br /> > > > <div style="width: 300 px;">6. De URL waar het probleem zich > > voordoet is:</div> > > <label id="label_right"><%= text_field ''helpdesk'', ''url'', :class > > => "txtfield", :size => 20 %></label><br /><br /> > > > <div style="width: 300 px;">7. Bestand toevoegen:</div> > > <%= file_field ''helpdesk'', ''file'', :class => "txtfield", :size => > > 20 %><br /><br /> > > > <div style="width: 300 px;">8. Het originele bestand heb ik > > bijgevoegd:</div> > > <%= radio_button "helpdesk", "bestand", "ja" %>ja<br /> > > <%= radio_button "helpdesk", "bestand", "nee" %>nee<br /><br /> > > > <div style="width: 550 px;">9. Graag zo volledig mogelijk > > omschrijven (stapsgewijs) wat het probleem / je vraag is.</div> > > <label id="label_right"><%= text_area ''helpdesk'', ''text'', :cols => > > "70", :rows => 20 %></label><br /><br /> > > > <div style="width: 550 px;">Hartelijk dank voor het invullen van > > bovenstaand formulier. Klik op versturen en wij streven ernaar binnen > > 5 werkdagen te reageren.</div> > > > <div><%= submit_tag "versturen", :onClick => "", :id => ''disable- > > me'' %></div><br /> > > </fieldset> > > </div> > > <% end %> > > > def ticket_with_attachment(browser, os, email, user_name, datum, > > url, file, bestand, text, sent_at = Time.now ) > > @subject = ''Helpdesk verzoek: '' + user_name > > @body = { :browser => browser, :os => os, :user_name => > > user_name, :email => email, :datum => datum, :url => url, :bestand => > > bestand, :text => text } > > @recipients = "x...-fdLVfzN/7KE@public.gmane.org" > > @from = "x...-fdLVfzN/7KE@public.gmane.org" > > @sent_on = sent_at > > unless file.blank? > > attachment :body => file.read, :filename => > > file.original_filename > > end > > end > > > That''s working code from one of our apps. Not very nice looking, but > > should do. > > Important parts are the file_field in the form (all others are just > > text or radio buttons) > > and those lines in the ActionMailer delivery method: > > > unless file.blank? > > attachment :body => file.read, :filename => file.original_filename > > end > > > which will attach the file to the mail--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---