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 [email protected]
Sent mail to [email protected]
Redirected to http://mlahsa.de/anzeige/suchmaske
Completed in 1764ms (DB: 1) | 302 Found
[http://mlahsa.einar-kretzler.de/anzeige/gruppenmail_schreiben]

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to