Hi marcel, I modified the code as you said. I'm unable to
revert the operation after receiving the file, the contents
gets deleted, Can you please check the code below.


//Sending message------>
Qt Code:
  1. void SynsupMail::sendMessage()
  2. {
  3. string msg;
  4. QFile f ( textFilename->text() );
  5. if ( f.open (IO_ReadOnly) )
  6. {
  7. // file opened successfully
  8. dat = f.readAll();
  9. }
  10. else
  11. {
  12. // problems opening the file - emit a warning message
  13. QMessageBox::warning( this, tr("error"),
  14. tr("Error opening file %1").arg( textFilename->text() ) );
  15. enableSubmit();
  16. return;
  17. }
  18. f.close();
  19. StringSource ( string(QString(dat).data()), true, new Base64Encoder(new StringSink(msg)));
  20. Smtp *smtp = new Smtp( textFrom->text(), textTo->text(),
  21. textSubject->text(),
  22. QString(msg.data()), fileName );
  23. }
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. Smtp::Smtp( const QString &from, const QString &to,
  2. const QString &subject,
  3. const QString &body, const QString &fileName)
  4. {
  5. address = QString::fromLatin1( "From: " ) + from +
  6. QString::fromLatin1( "\nTo: " ) + to +
  7. QString::fromLatin1( "\nSubject: " ) + subject + "\n";
  8.  
  9. message = QString::fromLatin1( "\n\n" ) + body + "\n";
  10.  
  11. /*replace( message, QString::fromLatin1( "\n" ),
  12. QString::fromLatin1( "\r\n" ) );*/
  13. replace( message, QString::fromLatin1( "\r\n.\r\n" ),
  14. QString::fromLatin1( "\r\n..\r\n" ) );
  15. replace( address, QString::fromLatin1( "\n" ),
  16. QString::fromLatin1( "\r\n" ) );
  17. replace( address, QString::fromLatin1( "\r\n.\r\n" ),
  18. QString::fromLatin1( "\r\n..\r\n" ) );
  19. }
To copy to clipboard, switch view to plain text mode 
//Receiving message------>
Qt Code:
  1. int SysupClass::openFile( const char* infile )
  2. {
  3. QFile f ( infile );
  4. if ( f.open (IO_ReadOnly) )
  5. {
  6. // file opened successfully
  7. dat = f.readAll();
  8. }
  9. else
  10. {
  11. f.close();
  12. return -1;
  13. }
  14. f.close();
  15.  
  16. //Here I might not be correct to reverse the operation
  17. //i.e removing \r\n..\r\n
  18. /*QString ss = dat;
  19. replace( ss, QString::fromLatin1( "\r\n..\r\n" ),
  20.   QString::fromLatin1( "\r\n.\r\n" ) );*/
  21.  
  22. QFile f1 ( strcat(infile, ".mod") );
  23. if ( f1.open (IO_WriteOnly|IO_Truncate) )
  24. {
  25. // file opened successfully
  26. f1.writeBlock(ss, ss.length());
  27. }
  28. f1.close();
  29.  
  30. //decrypt the file with AES::CBC mode
  31. }
To copy to clipboard, switch view to plain text mode 
wysota--->
I'm unable to understand these points
3. divide it into blocks 64 (or 80 or whatever) bytes each ---- need some more explanation
4. concatenate blocks using newlines (\r\n) ----- ---- need some more explanation
5. pass the result into the mail stream adding a base64 header --------- ---- need some more explanations
If possible please correct me with my code above and tell me how can I achieve the above three points