• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

KMIME Library

  • KMime
  • Message
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
KMime::Message Class Reference

#include <kmime_message.h>

Inheritance diagram for KMime::Message:
Inheritance graph
[legend]

Public Types

typedef QList< KMime::Message * > List
 
typedef boost::shared_ptr
< Message > 
Ptr
 
- Public Types inherited from KMime::Content
typedef QList< KMime::Content * > List
 

Public Member Functions

 Message ()
 
 ~Message ()
 
virtual KMime::Headers::Bcc * bcc (bool create=true)
 
virtual KMime::Headers::Cc * cc (bool create=true)
 
virtual void clear ()
 
virtual KMime::Headers::Date * date (bool create=true)
 
virtual KMime::Headers::From * from (bool create=true)
 
virtual KMIME_DEPRECATED
KMime::Headers::Base * 
getHeaderByType (const char *type)
 
virtual KMime::Headers::Base * headerByType (const char *type)
 
virtual KMime::Headers::InReplyTo * inReplyTo (bool create=true)
 
virtual bool isTopLevel () const
 
Content * mainBodyPart (const QByteArray &type=QByteArray())
 
virtual KMime::Headers::MessageID * messageID (bool create=true)
 
virtual
KMime::Headers::Organization * 
organization (bool create=true)
 
virtual void parse ()
 
virtual
KMime::Headers::References * 
references (bool create=true)
 
virtual bool removeHeader (const char *type)
 
virtual KMime::Headers::ReplyTo * replyTo (bool create=true)
 
virtual KMime::Headers::Sender * sender (bool create=true)
 
virtual void setHeader (KMime::Headers::Base *h)
 
virtual KMime::Headers::Subject * subject (bool create=true)
 
virtual KMime::Headers::To * to (bool create=true)
 
virtual KMime::Headers::UserAgent * userAgent (bool create=true)
 
- Public Member Functions inherited from KMime::Content
 Content ()
 
 Content (Content *parent)
 
 Content (const QByteArray &head, const QByteArray &body)
 
 Content (const QByteArray &head, const QByteArray &body, Content *parent)
 
virtual ~Content ()
 
void addContent (Content *content, bool prepend=false)
 
void appendHeader (Headers::Base *h)
 
virtual void assemble ()
 
List attachments (bool incAlternatives=false)
 
QByteArray body () const
 
boost::shared_ptr< Message > bodyAsMessage () const
 
bool bodyIsMessage () const
 
void changeEncoding (Headers::contentEncoding e)
 
void clearContents (bool del=true)
 
Content * content (const ContentIndex &index) const
 
Headers::ContentDescription * contentDescription (bool create=true)
 
Headers::ContentDisposition * contentDisposition (bool create=true)
 
Headers::ContentID * contentID (bool create=true)
 
Headers::ContentLocation * contentLocation (bool create=true)
 
List contents () const
 
Headers::ContentTransferEncoding * contentTransferEncoding (bool create=true)
 
Headers::ContentType * contentType (bool create=true)
 
QByteArray decodedContent ()
 
QString decodedText (bool trimText=false, bool removeTrailingNewlines=false)
 
QByteArray defaultCharset () const
 
QByteArray encodedBody ()
 
QByteArray encodedContent (bool useCrLf=false)
 
QByteArray epilogue () const
 
bool forceDefaultCharset () const
 
void fromUnicodeString (const QString &s)
 
KMIME_DEPRECATED Headers::Generic * getNextHeader (QByteArray &head)
 
bool hasContent () const
 
bool hasHeader (const char *type)
 
QByteArray head () const
 
template<typename T >
T * header (bool create=false)
 
template<class T >
T * headerInstance (T *, bool create)
 
virtual QList< Headers::Base * > headersByType (const char *type)
 
ContentIndex index () const
 
ContentIndex indexForContent (Content *content) const
 
bool isFrozen () const
 
int lineCount () const
 
KMIME_DEPRECATED Headers::Generic * nextHeader (QByteArray &head)
 
Content * parent () const
 
QByteArray preamble () const
 
void prependHeader (Headers::Base *h)
 
void removeContent (Content *content, bool del=false)
 
void setBody (const QByteArray &body)
 
void setContent (const QList< QByteArray > &l)
 
void setContent (const QByteArray &s)
 
void setDefaultCharset (const QByteArray &cs)
 
void setEpilogue (const QByteArray &epilogue)
 
virtual void setForceDefaultCharset (bool b)
 
void setFrozen (bool frozen=true)
 
void setHead (const QByteArray &head)
 
void setParent (Content *parent)
 
void setPreamble (const QByteArray &preamble)
 
int size ()
 
int storageSize () const
 
Content * textContent ()
 
Content * topLevel () const
 
void toStream (QTextStream &ts, bool scrambleFromLines=false)
 

Static Public Member Functions

static QString mimeType ()
 

Protected Member Functions

virtual QByteArray assembleHeaders ()
 
- Protected Member Functions inherited from KMime::Content
bool decodeText ()
 
template<class T >
KMIME_DEPRECATED T * headerInstance (T *ptr, bool create)
 
KMIME_DEPRECATED QByteArray rawHeader (const char *name) const
 
KMIME_DEPRECATED QList
< QByteArray > 
rawHeaders (const char *name) const
 

Additional Inherited Members

- Protected Attributes inherited from KMime::Content
Headers::Base::List h_eaders
 

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 );
m->contentTransferEncoding()->clear();
// Set the headers.
m->from()->fromUnicodeString( "some@mailaddy.com", "utf-8" );
m->to()->fromUnicodeString( "someother@mailaddy.com", "utf-8" );
m->cc()->fromUnicodeString( "some@mailaddy.com", "utf-8" );
m->date()->setDateTime( KDateTime::currentLocalDateTime() );
m->subject()->fromUnicodeString( "My Subject", "utf-8" );
// Set the first multipart, the body message.
KMime::Content *b = new KMime::Content;
b->contentType()->setMimeType( "text/plain" );
b->setBody( "Some text..." );
// Set the second multipart, the attachment.
KMime::Content *a = new KMime::Content;
KMime::Headers::ContentDisposition *d = new KMime::Headers::ContentDisposition( attachMessage );
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 81 of file kmime_message.h.

Member Typedef Documentation

typedef QList<KMime::Message*> KMime::Message::List

A list of messages.

Definition at line 87 of file kmime_message.h.

typedef boost::shared_ptr<Message> KMime::Message::Ptr

A shared pointer to a message object.

Definition at line 92 of file kmime_message.h.

Constructor & Destructor Documentation

KMime::Message::Message ( )

Creates an empty Message.

Definition at line 34 of file kmime_message.cpp.

KMime::Message::~Message ( )

Destroys this Message.

Definition at line 44 of file kmime_message.cpp.

Member Function Documentation

QByteArray KMime::Message::assembleHeaders ( )
protectedvirtual

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.

Definition at line 54 of file kmime_message.cpp.

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

Returns the Bcc header.

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

Returns the Cc header.

Parameters
createIf true, create the header if it doesn't exist yet.
void KMime::Message::clear ( )
virtual

Clears the content, deleting all headers and sub-Contents.

Reimplemented from KMime::Content.

Definition at line 68 of file kmime_message.cpp.

virtual KMime::Headers::Date* KMime::Message::date ( bool  create = true)
virtual

Returns the Date header.

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

Returns the From header.

Parameters
createIf true, create the header if it doesn't exist yet.
Headers::Base * KMime::Message::getHeaderByType ( const char *  type)
virtual

Tries to find a type header in the Content and returns it.

Parameters
typethe header type to find
Deprecated:
Use headerByType( const char * )

Reimplemented from KMime::Content.

Definition at line 74 of file kmime_message.cpp.

Headers::Base * KMime::Message::headerByType ( const char *  type)
virtual

Returns the first header of type type, if it exists.

Otherwise returns 0. Note that the returned header may be empty.

Parameters
typethe header type to find
Since
4.2

Reimplemented from KMime::Content.

Definition at line 80 of file kmime_message.cpp.

virtual KMime::Headers::InReplyTo* KMime::Message::inReplyTo ( bool  create = true)
virtual

Returns the In-Reply-To header.

Parameters
createIf true, create the header if it doesn't exist yet.
bool KMime::Message::isTopLevel ( ) const
virtual

Returns true if this is the top-level node in the MIME tree.

The top-level node is always a Message or NewsArticle. However, a node can be a Message without being a top-level node when it is an encapsulated message.

Reimplemented from KMime::Content.

Definition at line 98 of file kmime_message.cpp.

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 103 of file kmime_message.cpp.

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

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 140 of file kmime_message.cpp.

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

Returns the Organization header.

Parameters
createIf true, create the header if it doesn't exist yet.
void KMime::Message::parse ( )
virtual

Parses the Content.

This means the broken-down object representation of the Content is updated from the string representation of the Content.

Call this if you want to access or change headers, sub-Contents or the encapsulated message.

Note
Calling parse() twice will not work for multipart contents or for contents of which the body is an encapsulated message. The reason is that the first parse() will delete the body, so there is no body to work on for the second call of parse().
Calling this will reset the message returned by bodyAsMessage(), as the message is re-parsed as well. Also, all old sub-contents will be deleted, so any old Content pointer will become invalid.

Reimplemented from KMime::Content.

Definition at line 48 of file kmime_message.cpp.

virtual KMime::Headers::References* KMime::Message::references ( bool  create = true)
virtual

Returns the References header.

Parameters
createIf true, create the header if it doesn't exist yet.
bool KMime::Message::removeHeader ( const char *  type)
virtual

Searches for the first header of type type, and deletes it, removing it from this Content.

Parameters
typeThe type of the header to look for.
Returns
true if a header was found and removed.

Reimplemented from KMime::Content.

Definition at line 92 of file kmime_message.cpp.

virtual KMime::Headers::ReplyTo* KMime::Message::replyTo ( bool  create = true)
virtual

Returns the Reply-To header.

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

Returns the Sender header.

Parameters
createIf true, create the header if it doesn't exist yet.
void KMime::Message::setHeader ( KMime::Headers::Base *  h)
virtual

Sets the specified header to this Content.

Any previous header of the same type is removed. If you need multiple headers of the same type, use appendHeader() or prependHeader().

Parameters
hThe header to set.
See also
appendHeader()
removeHeader()
Since
4.4

Reimplemented from KMime::Content.

Definition at line 86 of file kmime_message.cpp.

virtual KMime::Headers::Subject* KMime::Message::subject ( bool  create = true)
virtual

Returns the Subject header.

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

Returns the To header.

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

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:
  • kmime_message.h
  • kmime_message.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KMIME Library

Skip menu "KMIME Library"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal