[Kde-pim] Question about details: HTML in email

Thomas McGuire mcguire at kde.org
Wed Mar 31 15:06:39 BST 2010


Hi,

On Wednesday 31 March 2010 15:49:28 Shen Miren wrote:
> I'm confused about how the HTML code store in the email.
> 
> I try to save some of my HTML email into xxx.mbox, and then I look into the
> source, and it come up like this:
> -----------------------------
> ...
> Content-Type: text/html;
>     charset="utf-8"
> Content-Transfer-Encoding: quoted-printable
> 
> <style type=3D'text/css'>
> ...
> </style>
> <table>
> ....
> </table>
> ...
> --------------------------
> So, is the HTML code just have the original content from <body></body>
> label ?

It depends, most of the time it includes the <body> and <html> tags as well. I 
actually thought KMail would include the <body> and the <html> tag when 
creating a mail, strange.

> As for the KMail, can someone show me the related code about
> fetching/converting/storing HTML content from/to KMime::Message ?

For displaying a HTML mail, see ObjectTreeParser::processTextHtmlSubtype() in 
kdepim/messageviewer/objecttreeparser.cpp. Basically we take the content of 
the text/html MIME part and add that to the HTML output of the viewer (and we 
strip the <body> and the <html> tag if they exist).

I recommend going to api.kde.org and read the documentation about the 
"messageviewer" component in KDEPIM for more details.

For creating a HTML mail, see the messagecomposer library in kdepim, in 
particular MainTextJobPrivate::createHtmlJob() and MainTextJob::doStart() in 
maintextjob.cpp

For editing a HTML mail in the composer, see KMComposeWin::setMsg(), see the 
part that has the comment "Set the HTML text and collect HTML images".

Reading the overview page of KMime in kdepimlibs is also useful to know how 
MIME mails work.

As you know already, the templateparser in kmail/templateparser.cpp does not 
deal with HTML mails currently: It creates a plain text mail only.
When replying or inline-forwarding a message, the template parser creates a 
reply/a forward, and then KMComoposeWin::setMsg() is called with that 
generated message.

Hope that helps a bit!

Regards,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20100331/6147aaeb/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