I need to send a excel sheet by emmail.
I’m using Action mailer like this:
class SimpleMailer < ActionMailer::Base
def the_message(asunto, message, recipient, file)
from ‘[email protected]’
subject asunto
body message
recipients recipient
if File.file? file
attachment :content_type => 'application/octet-stream',
:body => (File.read(file)),
:filename => (file =~ /.*\/(.*)$/ ? $1 : file),
:encoding => 'Base64'
end
end
end
…
SimpleMailer.deliver_the_message(“My subject”,
“My message”,
“[email protected]”,
excel_file_name)
PROBLEM:
When the mail is built the original file, 11kb in size, is encoded to
4,7 kb.
I also tried by supplying only the body of the message. It fails anyway.
Do you know how to fix this? Thanks!
Here is the header of the email:
Return-Path: [email protected]
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: by lijasdoblea.com (Postfix, from userid 501)
id 9A5B217989; Thu, 31 May 2007 15:06:28 -0300 (ART)
Received: from lijasdoblea.com (unknown [200.49.86.130])
by lijasdoblea.com (Postfix) with ESMTP id E8AC41797E
for [email protected]; Thu, 31 May 2007 15:06:26 -0300 (ART)
Date: Thu, 31 May 2007 14:58:08 -0300
From: [email protected]
To: [email protected]
Message-Id: [email protected]
Subject: Listado de control etiquetas, 31.05.2007
Mime-Version: 1.0
Content-Type: multipart/mixed;
boundary=mimepart_465f0cb02c308_9cc14263a428a
X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on
lijasdoblea.redesdelsur.com
X-Spam-Level:
X-Spam-Status: No, score=-99.8 required=4.0 tests=NO_REAL_NAME,
USER_IN_WHITELIST autolearn=no version=3.0.3
X-UIDL: E_p"![8i!!Ud!#!V#,!!
–mimepart_465f0cb02c308_9cc14263a428a
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Adjunto el listado de control de etiquetas en formato excel.
Saludos.
–mimepart_465f0cb02c308_9cc14263a428a
Content-Type: application/octet-stream;
name=listado_control_31.05.2007_2508.xls
Content-Transfer-Encoding: Base64
Content-Disposition: attachment;
filename=listado_control_31.05.2007_2508.xls
0M8R4KGxAAYADwAIADMwLzA1LzA3BAISAAwABwAPAAoAMTQ6NTU6MDcuNQQC
RQAMAAgADwA9AEJBTkRBUyBQQVBFTCBPQS5SRVMuRkVOT0JPTkQgICAgICAg
ICAgICAgICAgIDE1MFg3NjAwICAgICAgNjADAg4ADQAAAA8AAAAA0ATvfEED
more base 64 data then:
AwIOACEAAQAPAAAAAOA=
–mimepart_465f0cb02c308_9cc14263a428a–