Attachement corrupt

I’m using ActionMailer to send an e-mail with attachement, but I
receive the same e-mail attachement corrupted.

How I can resolve that?

The enviroment is:

  • Windows
  • Microsoft Exchange Server.

Code Enviroment.rb:

  1. ActionMailer::Base.delivery_method = :smtp
  2. ActionMailer::Base.smtp_settings = {
  3. :address => ‘nome_do_servidor’,
  4. :port => 25,
  5. :domain => nil
  6. }

Code Method to send e-mail:

  1. def enviar(mensagem)
  2. @subject = mensagem.assunto
  3. @body = {:mensagem => mensagem}
  4. @recipients = mensagem.para
  5. @from = mensagem.de
  6. @sent_on = Time.now
  7. @headers = {}
  8. unless mensagem.arquivos.blank?
  9. arquivo = mensagem.arquivos
    
  10. attachment(:filename => File.basename(arquivo)) do |a|
    
  11.   file = File.open(arquivo, 'r+') {|f| a.body =
    

f.read}
13. end
14. end
15. end

Thanks,

Daskandonga