[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:
    @
    bool Smtp::MakeAttachment(const QString &qsFileName)
    {
    bool bFileOpen(false);
    QFile qfFile(qsFileName);
    QFileInfo fi(qfFile);
    QString stType("application/octet-stream");
    QString stName = fi.fileName();

    qDebug() << qsFileName;
    
    if (qfFile.open(QIODevice::ReadWrite) == true)              // ReadWrite use because we want only write the mail if the file is not already opend.
    {                                                           // And we kan only write if the file is not already opend
        QByteArray content = qfFile.readAll();
        qfFile.close();
    
        stHeader += "Content-disposition: attachment\r\n";
        //  Header Prepare
        // Content-Type
        message.append("Content-Type: ").append(stType);
        message.append("; name=\"").append(stName).append("\"");
        message.append("\r\n");
    
        message.append("Content-Transfer-Encoding: ");
        message.append("base64\r\n");
    
        message.append(stHeader).append("\r\n");
        //  End of Header Prepare
        //  Content Encoding
        message.append(content.toBase64());
        message.append("\r\n");
        //  End of Content Encoding
        bFileOpen = true;
    }
    qDebug() << "File Open: " << bFileOpen;
    return bFileOpen;
    

    }
    @
    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!



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.