KMime::Message Class
class KMime::MessageRepresents a (email) message. More...
| Header: | #include <KMime/Message> |
| CMake: | find_package(KPim6 REQUIRED COMPONENTS Mime)target_link_libraries(mytarget PRIVATE KPim6::Mime) |
| Inherits: | KMime::Content |
| Inherited By: |
Public Functions
| Message() | |
(since 24.08) const KMime::Headers::Bcc * | bcc() const |
| KMime::Headers::Bcc * | bcc(KMime::CreatePolicy create = Create) |
(since 24.08) const KMime::Headers::Cc * | cc() const |
| KMime::Headers::Cc * | cc(KMime::CreatePolicy create = Create) |
(since 24.08) const KMime::Headers::Date * | date() const |
| KMime::Headers::Date * | date(KMime::CreatePolicy create = Create) |
(since 24.08) const KMime::Headers::From * | from() const |
| KMime::Headers::From * | from(KMime::CreatePolicy create = Create) |
(since 24.08) const KMime::Headers::InReplyTo * | inReplyTo() const |
| KMime::Headers::InReplyTo * | inReplyTo(KMime::CreatePolicy create = Create) |
| KMime::Content * | mainBodyPart(const QByteArray &type = QByteArray()) |
(since 24.08) const KMime::Headers::MessageID * | messageID() const |
| KMime::Headers::MessageID * | messageID(KMime::CreatePolicy create = Create) |
(since 24.08) const KMime::Headers::Organization * | organization() const |
| KMime::Headers::Organization * | organization(KMime::CreatePolicy create = Create) |
(since 24.08) const KMime::Headers::References * | references() const |
| KMime::Headers::References * | references(KMime::CreatePolicy create = Create) |
(since 24.08) const KMime::Headers::ReplyTo * | replyTo() const |
| KMime::Headers::ReplyTo * | replyTo(KMime::CreatePolicy create = Create) |
(since 24.08) const KMime::Headers::Sender * | sender() const |
| KMime::Headers::Sender * | sender(KMime::CreatePolicy create = Create) |
(since 24.08) const KMime::Headers::Subject * | subject() const |
| KMime::Headers::Subject * | subject(KMime::CreatePolicy create = Create) |
(since 24.08) const KMime::Headers::To * | to() const |
| KMime::Headers::To * | to(KMime::CreatePolicy create = Create) |
(since 24.08) const KMime::Headers::UserAgent * | userAgent() const |
| KMime::Headers::UserAgent * | userAgent(KMime::CreatePolicy create = Create) |
Static Public Members
| QString | mimeType() |
Detailed Description
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() ); Headers::ContentTransferEncoding *cte = m->contentTransferEncoding(); cte->setEncoding(Headers::CE7Bit); // Set the headers. m->from()->fromUnicodeString("some@mailaddy.com"); m->to()->fromUnicodeString("someother@mailaddy.com"); m->cc()->fromUnicodeString("some@mailaddy.com"); m->date()->setDateTime(QDateTime::currentLocalDateTime()); m->subject()->fromUnicodeString("My Subject"); // 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->appendContent( b ); m->appendContent( a ); m->assemble();
Member Function Documentation
Message::Message()
Creates an empty Message.
[since 24.08] const KMime::Headers::Bcc *Message::bcc() const
Returns the Bcc header.
Can be nullptr if the header doesn't exist.
This function was introduced in 24.08.
KMime::Headers::Bcc *Message::bcc(KMime::CreatePolicy create = Create)
Returns the Bcc header.
create Whether to create the header if it doesn't exist yet.
[since 24.08] const KMime::Headers::Cc *Message::cc() const
Returns the Cc header.
Can be nullptr if the header doesn't exist.
This function was introduced in 24.08.
KMime::Headers::Cc *Message::cc(KMime::CreatePolicy create = Create)
Returns the Cc header.
create Whether to create the header if it doesn't exist yet.
[since 24.08] const KMime::Headers::Date *Message::date() const
Returns the Date header.
Can be nullptr if the header doesn't exist.
This function was introduced in 24.08.
KMime::Headers::Date *Message::date(KMime::CreatePolicy create = Create)
Returns the Date header.
create Whether to create the header if it doesn't exist yet.
[since 24.08] const KMime::Headers::From *Message::from() const
Returns the From header.
Can be nullptr if the header doesn't exist.
This function was introduced in 24.08.
KMime::Headers::From *Message::from(KMime::CreatePolicy create = Create)
Returns the From header.
create Whether to create the header if it doesn't exist yet.
[since 24.08] const KMime::Headers::InReplyTo *Message::inReplyTo() const
Returns the In-Reply-To header.
Can be nullptr if the header doesn't exist.
This function was introduced in 24.08.
KMime::Headers::InReplyTo *Message::inReplyTo(KMime::CreatePolicy create = Create)
Returns the In-Reply-To header.
create Whether to create the header if it doesn't exist yet.
KMime::Content *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).
type The mimetype of the body part, if not given, the first body part will be returned, regardless of it's type.
[since 24.08] const KMime::Headers::MessageID *Message::messageID() const
Returns the Message-ID header.
Can be nullptr if the header doesn't exist.
This function was introduced in 24.08.
KMime::Headers::MessageID *Message::messageID(KMime::CreatePolicy create = Create)
Returns the Message-ID header.
create Whether to create the header if it doesn't exist yet.
[static] QString Message::mimeType()
Returns the MIME type used for Messages
[since 24.08] const KMime::Headers::Organization *Message::organization() const
Returns the Organization header.
Can be nullptr if the header doesn't exist.
This function was introduced in 24.08.
KMime::Headers::Organization *Message::organization(KMime::CreatePolicy create = Create)
Returns the Organization header.
create Whether to create the header if it doesn't exist yet.
[since 24.08] const KMime::Headers::References *Message::references() const
Returns the References header.
Can be nullptr if the header doesn't exist.
This function was introduced in 24.08.
KMime::Headers::References *Message::references(KMime::CreatePolicy create = Create)
Returns the References header.
create Whether to create the header if it doesn't exist yet.
[since 24.08] const KMime::Headers::ReplyTo *Message::replyTo() const
Returns the Reply-To header.
Can be nullptr if the header doesn't exist.
This function was introduced in 24.08.
KMime::Headers::ReplyTo *Message::replyTo(KMime::CreatePolicy create = Create)
Returns the Reply-To header.
create Whether to create the header if it doesn't exist yet.
[since 24.08] const KMime::Headers::Sender *Message::sender() const
Returns the Sender header.
Can be nullptr if the header doesn't exist.
This function was introduced in 24.08.
KMime::Headers::Sender *Message::sender(KMime::CreatePolicy create = Create)
Returns the Sender header.
create Whether to create the header if it doesn't exist yet.
[since 24.08] const KMime::Headers::Subject *Message::subject() const
Returns the Subject header.
Can be nullptr if the header doesn't exist.
This function was introduced in 24.08.
KMime::Headers::Subject *Message::subject(KMime::CreatePolicy create = Create)
Returns the Subject header.
create Whether to create the header if it doesn't exist yet.
[since 24.08] const KMime::Headers::To *Message::to() const
Returns the To header.
Can be nullptr if the header doesn't exist.
This function was introduced in 24.08.
KMime::Headers::To *Message::to(KMime::CreatePolicy create = Create)
Returns the To header.
create Whether to create the header if it doesn't exist yet.
[since 24.08] const KMime::Headers::UserAgent *Message::userAgent() const
Returns the User-Agent header.
Can be nullptr if the header doesn't exist.
This function was introduced in 24.08.
KMime::Headers::UserAgent *Message::userAgent(KMime::CreatePolicy create = Create)
Returns the User-Agent header.
create Whether to create the header if it doesn't exist yet.