Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] SMTP attachments not completed
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] SMTP attachments not completed

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JeroentjehomeJ Offline
    JeroentjehomeJ Offline
    Jeroentjehome
    wrote on last edited by
    #1

    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!

    Greetz, Jeroen

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

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

      Greetz, Jeroen

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved