[Kde-pim] Using kmime lib to create UTF-8 email message

David Jarvie djarvie at kde.org
Mon Jan 18 23:32:35 GMT 2010


I'm trying to use the kmime library to compile an email message in KAlarm, but can't get it to work with non-Latin scripts. I've looked at both mailody and the new kmail for inspiration, and can't see where I'm going wrong. For a plain text message with no attachments, I've tried 

   KMime::Message message;
   // Set headers ....
   message.contentType()->setMimeType("text/plain");
   // the message doesn't work with or without the following line:
   message.contentType()->setCharset("utf-8");
   message.setBody(bodyText.toUtf8());
   message.assemble();

I also tried, instead of setBody():

   message.fromUnicodeString(bodyText);

I retrieved the final QByteArray to send using

   message.encodedContent();

I've got non-Latin strings to work in the headers, but not in the body. When the body is displayed in kmail, it just shows gibberish. I'd much appreciate any pointers to how to fix it.

-- 
David Jarvie.
KDE developer.
KAlarm author -- http://www.astrojar.org.uk/kalarm
_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list