KMIME Library
KMime::Message Class Reference
Represents a (email) message. More...
#include <kmime_message.h>

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 79 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 85 of file kmime_message.h.
typedef boost::shared_ptr<Message> KMime::Message::Ptr |
A shared pointer to a message object.
Definition at line 90 of file kmime_message.h.
Constructor & Destructor Documentation
KMime::Message::Message | ( | ) |
Creates an empty Message.
Definition at line 32 of file kmime_message.cpp.
KMime::Message::~Message | ( | ) |
Destroys this Message.
Definition at line 42 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 52 of file kmime_message.cpp.
virtual KMime::Headers::Bcc* KMime::Message::bcc | ( | bool | create = true |
) | [virtual] |
Returns the Bcc header.
- Parameters:
-
create If 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:
-
create If 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 66 of file kmime_message.cpp.
virtual KMime::Headers::Date* KMime::Message::date | ( | bool | create = true |
) | [virtual] |
Returns the Date header.
- Parameters:
-
create If 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:
-
create If 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.
Reimplemented from KMime::Content.
Definition at line 72 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 78 of file kmime_message.cpp.
virtual KMime::Headers::InReplyTo* KMime::Message::inReplyTo | ( | bool | create = true |
) | [virtual] |
Returns the In-Reply-To header.
- Parameters:
-
create If 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, i.e.
if this is actually a Message or NewsArticle.
Reimplemented from KMime::Content.
Definition at line 96 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:
-
type The mimetype of the body part, if not given, the first body part will be returned, regardless of it's type.
Definition at line 101 of file kmime_message.cpp.
virtual KMime::Headers::MessageID* KMime::Message::messageID | ( | bool | create = true |
) | [virtual] |
Returns the Message-ID header.
- Parameters:
-
create If 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 137 of file kmime_message.cpp.
virtual KMime::Headers::Organization* KMime::Message::organization | ( | bool | create = true |
) | [virtual] |
Returns the Organization header.
- Parameters:
-
create If 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 or sub-Contents.
Reimplemented from KMime::Content.
Definition at line 46 of file kmime_message.cpp.
virtual KMime::Headers::References* KMime::Message::references | ( | bool | create = true |
) | [virtual] |
Returns the References header.
- Parameters:
-
create If 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:
-
type The type of the header to look for.
- Returns:
- true if a header was found and removed.
Reimplemented from KMime::Content.
Definition at line 90 of file kmime_message.cpp.
virtual KMime::Headers::ReplyTo* KMime::Message::replyTo | ( | bool | create = true |
) | [virtual] |
Returns the Reply-To header.
- Parameters:
-
create If 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:
-
create If 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:
-
h The header to set.
- See also:
- appendHeader()
- removeHeader()
- Since:
- 4.4
Reimplemented from KMime::Content.
Definition at line 84 of file kmime_message.cpp.
virtual KMime::Headers::Subject* KMime::Message::subject | ( | bool | create = true |
) | [virtual] |
Returns the Subject header.
- Parameters:
-
create If 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:
-
create If 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:
-
create If true, create the header if it doesn't exist yet.
The documentation for this class was generated from the following files: