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

Ingo Klöcker kloecker at kde.org
Mon Jan 18 23:46:19 GMT 2010


On Tuesday 19 January 2010, David Jarvie wrote:
> 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.

Just a wild guess, but did you try to set Content-transfer-encoding to 
8bit?


Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20100119/0ed814d5/attachment.sig>
-------------- next part --------------
_______________________________________________
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