sending Mail in loop w attachmt -> only 1.mail has the attachment

Hello, i have a Loop where an email is sent to several adresses one by one. works fine, but if i attach a file it works only for the first adress correctly. THe other get the mailtext, but no attachment (coorct name, but 0 Bytes) Any Idea why? TIA

Code of the controller: def gruppenmail_schreiben     puts "------------------"     attach = params[:attachment]     params[:auftragnr].each do |t|       if t != '0'         neuemail = Writtenmail.new         neuemail.attachment = attach         neuemail.betreff = params[:betreff]         neuemail.body = params[:body]         neuemail.candidate_id = t         neuemail.absender = current_fakusers.email         neuemail.email = mailsuchen(t)         neuemail.save         mailsenden(neuemail)       end

    end     redirect_to :controller => 'anzeige', :action => 'suchmaske'   end #Ende gruppenmail_schreiben

  def mailsenden(mail)       Notifier.deliver_multipart_alternative_rich(             #t,#             mail.email,             mail.betreff,             mail.body,             mail.candidate_id,             mail.attachment,             mail.absender             )     #end   end #Ende mailsenden

models/notifier Code:   def multipart_alternative_rich(email, betreff, inhalt, nr, anhang, absender, sent_at = Time.now)     require 'mime/types'

    @subject = betreff     @recipients = email     @from = absender     @sent_on = sent_at     @body = {:inhalt => inhalt}     @content_type = 'text/html'

    unless anhang.blank?       datentyp = typerkennung(anhang.original_filename)       puts datentyp       attachment :content_type => "'" + datentyp + "'",                   :body => anhang.read,                   :filename => anhang.original_filename     end   end

  def typerkennung(dateiname)      dateityp = MIME::Types.type_for(dateiname)      return dateityp[0]   end

The Log-Part: Processing AnzeigeController#gruppenmail_schreiben (for 193.25.32.138 at 2013-04-24 14:44:48) [POST]   Parameters: {"commit"=>"los", "body"=>"<p>fgdsg</p>", "attachment"=>#<File:/tmp/RackMultipart.24841.0>, "authenticity_token"=>"YGNJMTo4CBlONuQX+GlhfxBkIzCl5xz6u70zWY1fr/g=", "betreff"=>"test", "auftragnr"=>["0", "0", "0", "0", "0", "0", "124", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "16", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"]} Sent mail to e.eckh@loel.hs.de Sent mail to ekre@b.de Redirected to http://mlahsa.de/anzeige/suchmaske Completed in 1764ms (DB: 1) | 302 Found [http://mlahsa.einar-kretzler.de/anzeige/gruppenmail_schreiben\]

If the attachment is an IO like object (which seems like it is, from the log), then you’ll probably need to rewind it after it has been read.

Fred