libcurl corrupted attached file
-
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.
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 2019Any body can help me?
Best regards
Philippe
-
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.
-
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");