KMime::Message

Search for usage in LXR

#include <kmime_message.h>

Inheritance diagram for KMime::Message:

Public Types

typedef QSharedPointer< MessagePtr
 
- Public Types inherited from KMime::Content
typedef QVector< KMime::Content * > List
 

Public Member Functions

 Message ()
 
 ~Message () override
 
KMime::Headers::Bccbcc (bool create=true)
 
KMime::Headers::Cccc (bool create=true)
 
KMime::Headers::Datedate (bool create=true)
 
KMime::Headers::Fromfrom (bool create=true)
 
KMime::Headers::InReplyToinReplyTo (bool create=true)
 
ContentmainBodyPart (const QByteArray &type=QByteArray())
 
KMime::Headers::MessageIDmessageID (bool create=true)
 
KMime::Headers::Organizationorganization (bool create=true)
 
KMime::Headers::Referencesreferences (bool create=true)
 
KMime::Headers::ReplyToreplyTo (bool create=true)
 
KMime::Headers::Sendersender (bool create=true)
 
KMime::Headers::Subjectsubject (bool create=true)
 
KMime::Headers::Toto (bool create=true)
 
KMime::Headers::UserAgentuserAgent (bool create=true)
 
- Public Member Functions inherited from KMime::Content
 Content (Content *parent=nullptr)
 
virtual ~Content ()
 
void addContent (Content *content, bool prepend=false)
 
void appendHeader (Headers::Base *h)
 
void assemble ()
 
QVector< Content * > attachments ()
 
QByteArray body () const
 
QSharedPointer< MessagebodyAsMessage () const
 
bool bodyIsMessage () const
 
void changeEncoding (Headers::contentEncoding e)
 
void clear ()
 
void clearContents (bool del=true)
 
Contentcontent (const ContentIndex &index) const
 
Headers::ContentDescriptioncontentDescription (bool create=true)
 
Headers::ContentDispositioncontentDisposition (bool create=true)
 
Headers::ContentIDcontentID (bool create=true)
 
Headers::ContentLocationcontentLocation (bool create=true)
 
QVector< Content * > contents () const
 
Headers::ContentTransferEncodingcontentTransferEncoding (bool create=true)
 
Headers::ContentTypecontentType (bool create=true)
 
QByteArray decodedContent ()
 
QString decodedText (bool trimText=false, bool removeTrailingNewlines=false)
 
QByteArray encodedBody ()
 
QByteArray encodedContent (bool useCrLf=false)
 
QByteArray epilogue () const
 
void fromUnicodeString (const QString &s)
 
bool hasContent () const
 
bool hasHeader (const char *type) const
 
QByteArray head () const
 
template<typename T >
T * header (bool create=false)
 
Headers::BaseheaderByType (const char *type) const
 
QVector< Headers::Base * > headers () const
 
QVector< Headers::Base * > headersByType (const char *type) const
 
ContentIndex index () const
 
ContentIndex indexForContent (Content *content) const
 
bool isFrozen () const
 
bool isTopLevel () const
 
int lineCount () const
 
Contentparent () const
 
void parse ()
 
QByteArray preamble () const
 
void removeContent (Content *content, bool del=false)
 
bool removeHeader (const char *type)
 
template<typename T >
bool removeHeader ()
 
void replaceContent (Content *oldContent, Content *newContent)
 
void setBody (const QByteArray &body)
 
void setContent (const QByteArray &s)
 
void setEpilogue (const QByteArray &epilogue)
 
void setFrozen (bool frozen=true)
 
void setHead (const QByteArray &head)
 
void setHeader (Headers::Base *h)
 
void setParent (Content *parent)
 
void setPreamble (const QByteArray &preamble)
 
int size ()
 
int storageSize () const
 
ContenttextContent ()
 
ContenttopLevel () const
 

Static Public Member Functions

static QString mimeType ()
 
- Static Public Member Functions inherited from KMime::Content
static QByteArray defaultCharset ()
 

Protected Member Functions

QByteArray assembleHeaders () override
 

Detailed Description

Represents a (email) message.

Sample how to create a multipart message:

// Set the multipart message.
Message *m = new Message;
Headers::ContentType *ct = m->contentType();
ct->setMimeType( "multipart/mixed" );
ct->setBoundary( multiPartBoundary() );
ct->setCategory( Headers::CCcontainer );
Headers::ContentTransferEncoding *cte = m->contentTransferEncoding();
cte->setEncoding(Headers::CE7Bit);
cte->setDecoded(true);
// Set the headers.
m->from()->fromUnicodeString( "[email protected]", "utf-8" );
m->to()->fromUnicodeString( "[email protected]", "utf-8" );
m->cc()->fromUnicodeString( "[email protected]", "utf-8" );
m->date()->setDateTime( QDateTime::currentLocalDateTime() );
m->subject()->fromUnicodeString( "My Subject", "utf-8" );
// Set the first multipart, the body message.
b->contentType()->setMimeType( "text/plain" );
b->setBody( "Some text..." );
// Set the second multipart, the attachment.
d->setFilename( "cal.ics" );
d->setDisposition( KMime::Headers::CDattachment );
a->contentType()->setMimeType( "text/plain" );
a->setHeader( d );
a->setBody( "Some text in the attachment..." );
// Attach the both multiparts and assemble the message.
m->addContent( b );
m->addContent( a );
m->assemble();

Definition at line 66 of file kmime_message.h.

Member Typedef Documentation

A shared pointer to a message object.

Definition at line 72 of file kmime_message.h.

Constructor & Destructor Documentation

KMime::Message::Message ( )

Creates an empty Message.

Definition at line 19 of file kmime_message.cpp.

KMime::Message::~Message ( )
override

Destroys this Message.

Definition at line 23 of file kmime_message.cpp.

Member Function Documentation

QByteArray KMime::Message::assembleHeaders ( )
overrideprotectedvirtual

Reimplement this method if you need to assemble additional headers in a derived class.

Don't forget to call the implementation of the base class.

Returns
The raw, assembled headers.

Reimplemented from KMime::Content.

Reimplemented in KMime::NewsArticle.

Definition at line 27 of file kmime_message.cpp.

KMime::Headers::Bcc* KMime::Message::bcc ( bool  create = true)

Returns the Bcc header.

Parameters
createIf true, create the header if it doesn't exist yet.
KMime::Headers::Cc* KMime::Message::cc ( bool  create = true)

Returns the Cc header.

Parameters
createIf true, create the header if it doesn't exist yet.
KMime::Headers::Date* KMime::Message::date ( bool  create = true)

Returns the Date header.

Parameters
createIf true, create the header if it doesn't exist yet.
KMime::Headers::From* KMime::Message::from ( bool  create = true)

Returns the From header.

Parameters
createIf true, create the header if it doesn't exist yet.
KMime::Headers::InReplyTo* KMime::Message::inReplyTo ( bool  create = true)

Returns the In-Reply-To header.

Parameters
createIf true, create the header if it doesn't exist yet.
Content * KMime::Message::mainBodyPart ( const QByteArray type = QByteArray())

Returns the first main body part of a given type, taking multipart/mixed and multipart/alternative nodes into consideration.

Eg. bodyPart("text/html") will return a html content object if that is provided in a multipart/alternative node, but not if it's the non-first child node of a multipart/mixed node (ie. an attachment).

Parameters
typeThe mimetype of the body part, if not given, the first body part will be returned, regardless of it's type.

Definition at line 41 of file kmime_message.cpp.

KMime::Headers::MessageID* KMime::Message::messageID ( bool  create = true)

Returns the Message-ID header.

Parameters
createIf true, create the header if it doesn't exist yet.
QString KMime::Message::mimeType ( )
static

Returns the MIME type used for Messages.

Definition at line 79 of file kmime_message.cpp.

KMime::Headers::Organization* KMime::Message::organization ( bool  create = true)

Returns the Organization header.

Parameters
createIf true, create the header if it doesn't exist yet.
KMime::Headers::References* KMime::Message::references ( bool  create = true)

Returns the References header.

Parameters
createIf true, create the header if it doesn't exist yet.
KMime::Headers::ReplyTo* KMime::Message::replyTo ( bool  create = true)

Returns the Reply-To header.

Parameters
createIf true, create the header if it doesn't exist yet.
KMime::Headers::Sender* KMime::Message::sender ( bool  create = true)

Returns the Sender header.

Parameters
createIf true, create the header if it doesn't exist yet.
KMime::Headers::Subject* KMime::Message::subject ( bool  create = true)

Returns the Subject header.

Parameters
createIf true, create the header if it doesn't exist yet.
KMime::Headers::To* KMime::Message::to ( bool  create = true)

Returns the To header.

Parameters
createIf true, create the header if it doesn't exist yet.
KMime::Headers::UserAgent* KMime::Message::userAgent ( bool  create = true)

Returns the User-Agent header.

Parameters
createIf true, create the header if it doesn't exist yet.

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed May 12 2021 23:12:42 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.