mailserviceimpl.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifdef HAVE_CONFIG_H
00032 #include <config.h>
00033 #endif
00034
00035 #include "mailserviceimpl.h"
00036
00037 #include "kmcomposewin.h"
00038 #include "kmmessage.h"
00039 #include "kmmsgpart.h"
00040 #include "kmkernel.h"
00041
00042 #include <dcopobject.h>
00043 #include <kurl.h>
00044 #include <qcstring.h>
00045
00046 namespace KMail {
00047
00048
00049 MailServiceImpl::MailServiceImpl()
00050 : DCOPObject( "MailTransportServiceIface" )
00051 {
00052 }
00053
00054 bool MailServiceImpl::sendMessage( const QString& to, const QString& cc, const QString& bcc,
00055 const QString& subject, const QString& body,
00056 const KURL::List& attachments )
00057 {
00058 if ( to.isEmpty() && cc.isEmpty() && bcc.isEmpty() )
00059 return false;
00060
00061 KMMessage *msg = new KMMessage;
00062 msg->initHeader();
00063
00064 msg->setCharset( "utf-8" );
00065
00066 if ( !to.isEmpty() ) msg->setTo( to );
00067 if ( !cc.isEmpty() ) msg->setCc( cc );
00068 if ( !bcc.isEmpty() ) msg->setBcc( bcc );
00069 if ( !subject.isEmpty() ) msg->setSubject( subject );
00070 if ( !body.isEmpty() ) msg->setBody( body.utf8() );
00071
00072 KMComposeWin *cWin = new KMComposeWin( msg );
00073 cWin->setCharset("", TRUE);
00074
00075 for( KURL::List::ConstIterator itr = attachments.begin();
00076 itr != attachments.end(); ++itr ) {
00077 cWin->addAttachment( *itr, "" );
00078 }
00079
00080 cWin->send( 1 );
00081 return true;
00082 }
00083
00084 bool MailServiceImpl::sendMessage( const QString& to, const QString& cc, const QString& bcc,
00085 const QString& subject, const QString& body,
00086 const QByteArray& attachment )
00087 {
00088 if ( to.isEmpty() && cc.isEmpty() && bcc.isEmpty() )
00089 return false;
00090
00091 KMMessage *msg = new KMMessage;
00092 msg->initHeader();
00093
00094 msg->setCharset( "utf-8" );
00095
00096 if ( !to.isEmpty() ) msg->setTo( to );
00097 if ( !cc.isEmpty() ) msg->setCc( cc );
00098 if ( !bcc.isEmpty() ) msg->setBcc( bcc );
00099 if ( !subject.isEmpty() ) msg->setSubject( subject );
00100 if ( !body.isEmpty() ) msg->setBody( body.utf8() );
00101
00102 KMMessagePart *part = new KMMessagePart;
00103 part->setCteStr( "base64" );
00104 part->setBodyEncodedBinary( attachment );
00105 msg->addBodyPart( part );
00106
00107 KMComposeWin *cWin = new KMComposeWin( msg );
00108 cWin->setCharset("", TRUE);
00109 return true;
00110 }
00111
00112 }
00113
This file is part of the documentation for kmail Library Version 3.2.2.