From 2f8026dc5bb17e7fecf126070481e34a20485b67 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sun, 23 May 2010 16:18:00 +0000 Subject: Improved automatic encoding selection. Added helper functions on body for setting contents, type, charset and encoding. --- src/htmlTextPart.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/htmlTextPart.cpp') diff --git a/src/htmlTextPart.cpp b/src/htmlTextPart.cpp index 7713034f..c845b576 100644 --- a/src/htmlTextPart.cpp +++ b/src/htmlTextPart.cpp @@ -69,27 +69,20 @@ void htmlTextPart::generateIn(ref /* message */, ref paren ref part = vmime::create (); parent->getBody()->appendPart(part); - // -- Set header fields - part->getHeader()->ContentType()->setValue - (mediaType(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN)); - part->getHeader()->ContentType().dynamicCast ()->setCharset(m_charset); - part->getHeader()->ContentTransferEncoding()->setValue(encoding(encodingTypes::QUOTED_PRINTABLE)); - // -- Set contents - part->getBody()->setContents(m_plainText); + part->getBody()->setContents(m_plainText, + mediaType(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN), m_charset, + encoding::decide(m_plainText, m_charset, encoding::USAGE_TEXT)); } // HTML text // -- Create a new part ref htmlPart = vmime::create (); - // -- Set header fields - htmlPart->getHeader()->ContentType()->setValue(mediaType(mediaTypes::TEXT, mediaTypes::TEXT_HTML)); - htmlPart->getHeader()->ContentType().dynamicCast ()->setCharset(m_charset); - htmlPart->getHeader()->ContentTransferEncoding()->setValue(encoding(encodingTypes::QUOTED_PRINTABLE)); - // -- Set contents - htmlPart->getBody()->setContents(m_text); + htmlPart->getBody()->setContents(m_text, + mediaType(mediaTypes::TEXT, mediaTypes::TEXT_HTML), m_charset, + encoding::decide(m_text, m_charset, encoding::USAGE_TEXT)); // Handle the case we have embedded objects if (!m_objects.empty()) -- cgit v1.2.3