• Skip to content
  • Skip to link menu
KDE 4.8 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • Contact Us
 

KMIME Library

  • KMime
  • Message
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
KMime::Message Class Reference

#include <kmime_message.h>

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

List of all members.

Public Types

typedef QList< KMime::Message * > List
typedef boost::shared_ptr
< Message > 
Ptr

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::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)

Static Public Member Functions

static QString mimeType ()

Protected Member Functions

virtual QByteArray assembleHeaders ()

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.

Reimplemented from KMime::Content.

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 ( ) [protected, virtual]

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.

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.

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

KMIME Library

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal