July 18, 2012

Jeroentje@home Jeroentje@ho..
Hobby Entomologist
235 posts

[SOLVED] SMTP attachments not completed

 

Hi there, We have a problem with a GPRS connection to enable our device to send mails to our client so he is able to verify the operation of the unit. We have found a nice SMTP class that enables us to send mail and add attachments. All seems to work great and we send out the units into the field. We have a unit on a location where the GPRS connection is crap. Half of the time the connection is lost. The unit still tries to send the mail via SMTP. The client receives messages, but the attachment is not readable and when compared to the original is corrupt.
The code that creates the mail:

  1. bool Smtp::MakeAttachment(const QString &qsFileName)
  2. {
  3.     bool        bFileOpen(false);
  4.     QFile       qfFile(qsFileName);
  5.     QFileInfo   fi(qfFile);
  6.     QString     stType("application/octet-stream");
  7.     QString     stName = fi.fileName();
  8.    
  9.     qDebug() << qsFileName;
  10.  
  11.     if (qfFile.open(QIODevice::ReadWrite) == true)              // ReadWrite use because we want only write the mail if the file is not already opend.
  12.     {                                                           // And we kan only write if the file is not already opend
  13.         QByteArray content = qfFile.readAll();
  14.         qfFile.close();
  15.  
  16.         stHeader += "Content-disposition: attachment\r\n";
  17.         //  Header Prepare
  18.         // Content-Type
  19.         message.append("Content-Type: ").append(stType);
  20.         message.append("; name=\"").append(stName).append("\"");
  21.         message.append("\r\n");
  22.  
  23.         message.append("Content-Transfer-Encoding: ");
  24.         message.append("base64\r\n");
  25.  
  26.         message.append(stHeader).append("\r\n");
  27.         //  End of Header Prepare
  28.         //  Content Encoding
  29.         message.append(content.toBase64());
  30.         message.append("\r\n");
  31.         //  End of Content Encoding
  32.         bFileOpen = true;
  33.     }
  34.     qDebug() << "File Open: " << bFileOpen;
  35.     return bFileOpen;
  36. }

Is there a way to modify this code or the header generation so that the receiving SMTP server will drop the message when not received?
Is there a SMTP protocol command to drop the message if incomplete so our client doesn’t get corrupted data?
Thank already!

 Signature 

Greetz, Jeroen

1 reply

July 18, 2012

Jeroentje@home Jeroentje@ho..
Hobby Entomologist
235 posts

It was the Exchange server that just killed the xls files as being virus friendly.

 Signature 

Greetz, Jeroen

 
  ‹‹ qmake: check for environment variables      Qt3D - Change near clipping ››

You must log in to post a reply. Not a member yet? Register here!