|
|
Hi,
I want to extend the Smtp Qt example with attachements of generic MIME
type (images, text...).
I found the class QMimeSource quite useful, it provides me with the MIME
type and encodes the data for me (at least I think so) with
QMimeSource::encodeData(). It looks a bit like this so far:
QString attachment; // path to file to attach
...
QMimeSourceFactory *mimeSourceFactory =
QMimeSourceFactory::defaultFactory();
QMimeSource *mimeSource;
// setup the MIME source
mimeSourceFactory->setFilePath (attachment);
mimeSource = mimeSourceFactory->data (attachment);
QString multiPart = <text MIME part> +
// attachment
QString::fromLatin1 ("\n\n--%1").arg (mimeBoundary) +
QString::fromLatin1 ("\nContent-Type: %1").arg
(mimeSource->format()) +
// (1) how to determine the Encoding here? Must be e.g. 8bit
// for XML, BASE64 for binary data...
QString::fromLatin1 ("\nContent-Transfer-Encoding: BASE64") +
QString::fromLatin1 ("\nContent-Disposition: attachment;
filename=%1\n\n").arg (fileInfo.fileName()) +
// (2) does encodedData() e.g. for images really produce BASE64
// encoding?
QString (mimeSource->encodedData (mimeSource->format()));
...
<construct the SMTP message which contains the 'multiPart'>
Unclear to me are (1): is there a way to find out whether the MIME
source contains binary data or text data? And (2): the code as it is
fails e.g. for a JPEG image, I don't get the expected BASE64 encoding
(viewable in the qDebug output). Does encodeData() really produce BASE64
encoding for JPEG images (and other binary data)? Or did i misunderstand
the concept of QMimeSource here?
Thanks, Oliver
--
List archive and information: http://lists.trolltech.com/qt-interest/
|
|