# Problem sending excel sheets by email

**URL:** <https://www.ruby-forum.com/t/problem-sending-excel-sheets-by-email/105622>\
**Category:** Rails\
**Created:** [May 31, 2007, 8:17pm UTC](https://www.ruby-forum.com/t/problem-sending-excel-sheets-by-email/105622 "2007-05-31T20:17:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ActionMailerS\_probl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecd19e/32.png) [@ActionMailerS\_probl](https://www.ruby-forum.com/u/ActionMailerS_probl)\
**Post date:** [May 31, 2007, 8:17pm UTC](https://www.ruby-forum.com/t/problem-sending-excel-sheets-by-email/105622/1 "2007-05-31T20:17:38Z")

</div>

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 ‘removed\_email\_address@domain.invalid’  
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”,  
“removed\_email\_address@domain.invalid”,  
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: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
X-Original-To: removed\_email\_address@domain.invalid  
Delivered-To: removed\_email\_address@domain.invalid  
Received: by [lijasdoblea.com](http://lijasdoblea.com) (Postfix, from userid 501)  
id 9A5B217989; Thu, 31 May 2007 15:06:28 -0300 (ART)  
Received: from [lijasdoblea.com](http://lijasdoblea.com) (unknown [200.49.86.130])  
by [lijasdoblea.com](http://lijasdoblea.com) (Postfix) with ESMTP id E8AC41797E  
for [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid); Thu, 31 May 2007 15:06:26 -0300 (ART)  
Date: Thu, 31 May 2007 14:58:08 -0300  
From: removed\_email\_address@domain.invalid  
To: removed\_email\_address@domain.invalid  
Message-Id: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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](http://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–

---

<div class="post-metadata">

**Author:** ![ActionMailerS\_probl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecd19e/32.png) [@ActionMailerS\_probl](https://www.ruby-forum.com/u/ActionMailerS_probl)\
**Post date:** [May 31, 2007, 10:18pm UTC](https://www.ruby-forum.com/t/problem-sending-excel-sheets-by-email/105622/2 "2007-05-31T22:18:30Z")

</div>

Interestaing fact: THIS DOSN’T HAPPEN ON LINUX!!! Why???

I know 'cause i’ve tried it in my linux server and it worked all right.
