32 #include "mailserviceimpl.moc"
33 #include <serviceadaptor.h>
38 #include "messagecomposer/helper/messagehelper.h"
43 #include <QDBusConnection>
50 new ServiceAdaptor(
this );
51 QDBusConnection::sessionBus().registerObject( QLatin1String(
"/MailTransportService"),
this );
55 const QString& cc,
const QString& bcc,
56 const QString&
subject,
const QString& body,
57 const QStringList& attachments )
59 if ( to.isEmpty() && cc.isEmpty() && bcc.isEmpty() )
62 KMime::Message::Ptr msg(
new KMime::Message );
63 MessageHelper::initHeader( msg,
KMKernel::self()->identityManager() );
65 msg->contentType()->setCharset(
"utf-8" );
67 if ( !from.isEmpty() ) msg->from()->fromUnicodeString( from,
"utf-8" );
68 if ( !to.isEmpty() ) msg->to()->fromUnicodeString( to,
"utf-8" );
69 if ( !cc.isEmpty() ) msg->cc()->fromUnicodeString( cc,
"utf-8" );
70 if ( !bcc.isEmpty() ) msg->bcc()->fromUnicodeString( bcc,
"utf-8" );
71 if ( !subject.isEmpty() ) msg->subject()->fromUnicodeString( subject,
"utf-8" );
72 if ( !body.isEmpty() ) msg->setBody( body.toUtf8() );
76 KUrl::List attachUrls;
77 const int nbAttachments = attachments.count();
78 for (
int i = 0; i < nbAttachments; ++i ) {
79 attachUrls += KUrl( attachments[i] );
88 const QString& cc,
const QString& bcc,
89 const QString&
subject,
const QString& body,
90 const QByteArray& attachment )
92 if ( to.isEmpty() && cc.isEmpty() && bcc.isEmpty() )
95 KMime::Message::Ptr msg(
new KMime::Message );
96 MessageHelper::initHeader( msg,
KMKernel::self()->identityManager() );
98 msg->contentType()->setCharset(
"utf-8" );
100 if ( !from.isEmpty() ) msg->from()->fromUnicodeString( from,
"utf-8" );
101 if ( !to.isEmpty() ) msg->to()->fromUnicodeString( to,
"utf-8" );
102 if ( !cc.isEmpty() ) msg->cc()->fromUnicodeString( cc,
"utf-8" );
103 if ( !bcc.isEmpty() ) msg->bcc()->fromUnicodeString( bcc,
"utf-8" );
104 if ( !subject.isEmpty() ) msg->subject()->fromUnicodeString( subject,
"utf-8" );
105 if ( !body.isEmpty() ) msg->setBody( body.toUtf8() );
107 KMime::Content *part =
new KMime::Content;
108 part->contentTransferEncoding()->from7BitString(
"base64" );
109 part->setBody( attachment );
110 msg->addContent( part );
112 KMail::makeComposer( msg,
false,
false );
bool sendMessage(const QString &from, const QString &to, const QString &cc, const QString &bcc, const QString &subject, const QString &body, const QStringList &attachments)
virtual void addAttachmentsAndSend(const KUrl::List &urls, const QString &comment, int how)=0
static KMKernel * self()
normal control stuff