Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. libcurl corrupted attached file
Qt 6.12 LTS is out! See what's new in the release blog

libcurl corrupted attached file

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 1.0k Views 2 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.
  • F Offline
    F Offline
    filipdns
    wrote on last edited by
    #1

    Hello,

    When I attached simple jpeg file, the mail received has corrupted one like below, same for xlsx file, it can not be open due corrupted.

    test.jpeg url de l'image)

    part = curl_mime_addpart(alt);
    curl_mime_data(part, msg.toStdString().c_str(), CURL_ZERO_TERMINATED);
    curl_mime_type(part, "text/html; charset=utf-8 ");
    
    /* Create the inline part. */
    part = curl_mime_addpart(mime);
    curl_mime_subparts(part, alt);
    curl_mime_type(part, "multipart/alternative");
    slist = curl_slist_append(nullptr, "Content-Disposition: inline");
    curl_mime_headers(part, slist, 1);
    
    /* Add the current source program as an embbeded image. */
    part = curl_mime_addpart(mime);
    QString logo=QApplication::applicationDirPath()+"/Images/logo.jpeg";
    curl_mime_filedata(part, logo.toStdString().c_str());
    
    // Add the current source program as an attachment.
    part = curl_mime_addpart(mime);
    curl_mime_filedata(part, quotefile.toStdString().c_str());
    
    // Add the current source program as an attachment.
    /*part = curl_mime_addpart(mime);
    for(int i=0;i<fileList.count();i++)
    {
        QString filename="./"+fileList[i];
        if(fileList[i]!="")
            curl_mime_filedata(part, filename.toStdString().c_str());
    }*/
    curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
    
    /* Send the message */
    res = curl_easy_perform(curl);
    

    libcurl version 7.85
    operating system Qt 5.15.2 / Windows 10 / VS 2019

    Any body can help me?

    Best regards

    Philippe

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Since everything looks like done through curl, I would rather debug that part. The only Qt code here is the retrieval of the image path.

      You should reduce your code to the minimal that allows you to achieve what you want and then add the rest.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • M Offline
        M Offline
        mchinand
        wrote on last edited by
        #3

        Seems like this is primarily a curl issue; have you tried asking on the curl forum/list?

        1 Reply Last reply
        2
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          You are not setting a MIME type on the parts containing the JPEG image or the data from "quotefile". This may result in something the receiver has to assume (incorrectly).

          1 Reply Last reply
          0
          • F Offline
            F Offline
            filipdns
            wrote on last edited by
            #5

            I solved the issue with dfandrich suggestion, ising curl_mime_encoder:

            part = curl_mime_addpart(mime);
            QString logo=QApplication::applicationDirPath()+"/Images/logoIgn.jpeg";
            curl_mime_filedata(part, logo.toStdString().c_str());
            curl_mime_encoder(part, "base64");

            1 Reply Last reply
            2

            • Login

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