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

David Jarvie djarvie at kde.org
Tue Jan 19 19:08:27 GMT 2010


Hi Thomas,

On Tuesday 19 Jan 2010 00:04:03 Thomas McGuire wrote:
> On Tuesday 19 January 2010 00:32:35 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();
> 
> Hmm, setting the content type to text/plain and then calling 
> fromUnicodeString() with the QString as argument, followed by an assemble(), 
> should be enough.
> 
> If that doesn't work, can you attach the encodedContent() here so I can have a 
> closer look?

I attach the whole email text which was returned by encodedContent(). The two ways of producing it (setBody() and fromUnicodeString()) both produce the same result. The original body text was some Cyrillic text conveniently provided by a spam email which I was sent):

Під час клацання

Cheers,
-- 
David Jarvie.
KDE developer.
KAlarm author -- http://www.astrojar.org.uk/kalarm
-------------- next part --------------
Message-Id: <1539062.iZy1eekp9p at kde.org>
From: David Jarvie <djarvie at kde.org>
Subject: =?UTF-8?B?0J/RltC0INGH0LDRgSDQstGF0L7QtNGD?=
To: =??B?0JDQvdC+0L3QuNC8?= <xinulit at xxxecos.ua.xyz>
Date: Tue, 19 Jan 2010 18:51:24 +0000
User-Agent: KAlarm/2.2.10
MIME-Version: 1.0
Content-Type: text/plain;
  charset="utf-8"
Status: R
X-Status: N
X-KMail-EncryptionState:  
X-KMail-SignatureState:  
X-KMail-MDN-Sent:  

Під час клацання
-------------- 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