Forum: Ruby download files from mail

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.
Blanca I. (Guest)
on 2008-10-28 14:14
Hi,

I'm trying to download a file with net::IMAP from mail count. I can
download plain texts files using fetch method and unpack'm', but when i
try it with an excel file (vnd.ms-excel), the downloaded excel is
corrupted.

thanks for all
Artur J. (Guest)
on 2008-10-28 18:50
compare the files and detect de differences

bye

Blanca Id wrote:
> Hi,
>
> I'm trying to download a file with net::IMAP from mail count. I can
> download plain texts files using fetch method and unpack'm', but when i
> try it with an excel file (vnd.ms-excel), the downloaded excel is
> corrupted.
>
> thanks for all
Blanca I. (Guest)
on 2008-10-28 18:56
Hi Artur,

I have compared the excel file download from mail with the original and
seems to be the same. I've read that can be that the LF character has
been replaced with CRLF characters, so the download file size is
diferent.

thanks



Artur Juve wrote:
> compare the files and detect de differences
>
> bye
Blanca I. (Guest)
on 2008-10-28 19:34
Hi,

At last I found the solution, to download correctly excel files I use
the 'wb' instead of 'w' on the open parameters.

  if body.subtype == "PLAIN"
    File.open(nameFile,'w')
      f.write(file)
    end
  else
    File.open(nameFile,'wb')
      f.write(file)
    end
  end

bye
This topic is locked and can not be replied to.