Forum: Ruby Tmail: Saving Excel attachments to disk.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1fedb4cfb4c44df71b637e17034d1d64?d=identicon&s=25 Andrew M. Campbell (Guest)
on 2007-02-05 16:10
(Received via mailing list)
I'm using ActionMailer, which uses Tmail, to save
Excel attachments to disk.  I found a tutorial for
saving attachments.  However whether I decode the
message part or not.  Excel says the file is corrupt.
I'm using Windows XP, latest stable Ruby and latest
Rails gem.  The mails I receive are valid multipart
mail messages.  The spreadsheet attachments are valid
as well.  Any Suggestions on the proper way to save
Excel attachments using Tmail?

My code is very similar to this tutorial.  All I do is
check the content type of each part.  If it is an
Excel spreadsheet.  I push it onto an array.  Then
iterate over the array of spreadsheets, saving them to
disk.  The code I use to write to disk is identical to
the tutorial.
http://mondragon.cc/blog/articles/2006/12/30/decod...

Thanks,
97550977337c9f0a0e1a9553e55bfaa0?d=identicon&s=25 Jan Svitok (Guest)
on 2007-02-05 16:29
(Received via mailing list)
On 2/5/07, Andrew M. Campbell <listdata@sbcglobal.net> wrote:
> My code is very similar to this tutorial.  All I do is
> check the content type of each part.  If it is an
> Excel spreadsheet.  I push it onto an array.  Then
> iterate over the array of spreadsheets, saving them to
> disk.  The code I use to write to disk is identical to
> the tutorial.
> 
http://mondragon.cc/blog/articles/2006/12/30/decod...
>
> Thanks,

try adding "binary" to File.open() if you're on windows

you can check if this is your problem by sending a known file to
yourself and compare the sent and received files - if there's a
problem, they'd differ in length, just make sure the sent file
contains \n (13)
1fedb4cfb4c44df71b637e17034d1d64?d=identicon&s=25 Andrew M. Campbell (Guest)
on 2007-02-05 16:44
(Received via mailing list)
--- Jan Svitok <jan.svitok@gmail.com> wrote:

> multipart
> > iterate over the array of spreadsheets, saving
> them to
> > disk.  The code I use to write to disk is
> identical to
> > the tutorial.
> >
>
http://mondragon.cc/blog/articles/2006/12/30/decod...
> problem, they'd differ in length, just make sure the
> sent file
> contains \n (13)
>
>

Adding binary to File.open worked like a champ.  Thank
you.
This topic is locked and can not be replied to.