Results 1 to 2 of 2

Thread: Download attachments and Base64 coding

  1. #1
    Join Date
    Feb 2010
    Posts
    7
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Question Download attachments and Base64 coding

    I'm making tiny e-mail application downloading attachments from server POP3. I used QByteArray::fromBase64 to decode files. I haven't got problems with *.txt files but I can't download and save e.g. *.png files. Images files are dameged. This is my code:


    Qt Code:
    1. QByteArray hashAtt;
    2. for( ... )
    3. {
    4. (...)
    5. hashAtt.append(lines[i]);
    6. (...)
    7. }
    8.  
    9. QFile file(fileName);
    10.  
    11. if(file.open(QFile::WriteOnly | QFile ::Text))
    12. {
    13. QByteArray fileAtt = QByteArray::fromBase64(hashAtt);
    14. QTextStream out(&file);
    15. out << hashAtt;
    16. hashAtt.clear();
    17. }
    To copy to clipboard, switch view to plain text mode 


    What should I do to correctly download all attachments from host?

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Download attachments and Base64 coding

    On the image files that come out corrupted, what does the content-encoding header say?

    There's no guarantee that every mail client will use base64. It's the most common, but not the only encoding, hence the reason for the header.

Similar Threads

  1. QWidget Attachments
    By BingoMaster in forum Newbie
    Replies: 4
    Last Post: 27th September 2009, 21:07
  2. How can i decode binary base64
    By Askar in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2009, 03:01
  3. Replies: 0
    Last Post: 18th July 2009, 13:07
  4. SMTP & Attachments
    By cioannou in forum General Programming
    Replies: 2
    Last Post: 26th January 2006, 12:40

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.