MessageBuilder class
Simplifies creating mime messages for sending or storing.
- Inheritance
-
- Object
- PartBuilder
- MessageBuilder
Constructors
- MessageBuilder.new({String? text, TransferEncoding transferEncoding = TransferEncoding.automatic, CharacterSet? characterSet, ContentTypeHeader? contentType, HeaderEncoding subjectEncoding = HeaderEncoding.Q})
- Creates a new message builder and populates it with the optional data.
Properties
-
attachments
→ List<
AttachmentInfo> -
finalinherited
-
bcc
↔ List<
MailAddress> ? -
bcc
recpientsgetter/setter pair -
cc
↔ List<
MailAddress> ? -
cc
recpientsgetter/setter pair - characterSet ↔ CharacterSet?
-
getter/setter pairinherited
- chatGroupId ↔ String?
-
Specify in case this is a chat group discussion
getter/setter pair
- contentDisposition ↔ ContentDispositionHeader?
-
getter/setter pairinherited
- contentType ↔ ContentTypeHeader?
-
getter/setter pairinherited
- date ↔ DateTime?
-
Message date
getter/setter pair
-
from
↔ List<
MailAddress> ? -
List of senders, typically this is only one sender
getter/setter pair
- hasAttachments → bool
-
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isChat ↔ bool
-
Set to
true
to set chat headersgetter/setter pair - messageId ↔ String?
-
ID of the message
getter/setter pair
- originalMessage ↔ MimeMessage?
-
Reference to original message
getter/setter pair
- replyToSimplifyReferences ↔ bool
-
Set to
true
in case only the last replied to message should be referenced. Useful for long threads.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sender ↔ MailAddress?
-
One sender in case there are different
from
sendersgetter/setter pair - subject ↔ String?
-
Message subject
getter/setter pair
- subjectEncoding ↔ HeaderEncoding
-
Header encoding type
getter/setter pair
- text ↔ String?
-
getter/setter pairinherited
-
to
↔ List<
MailAddress> ? -
to
recpientsgetter/setter pair - transferEncoding ↔ TransferEncoding
-
getter/setter pairinherited
Methods
-
addBinary(
Uint8List data, MediaType mediaType, {TransferEncoding transferEncoding = TransferEncoding.base64, ContentDispositionHeader? disposition, String? filename}) → PartBuilder -
Adds a binary data part with the given
data
and optionalfilename
.inherited -
addFile(
File file, MediaType mediaType, {ContentDispositionHeader? disposition}) → Future< PartBuilder> -
Adds the
file
part asyncronously.inherited -
addHeader(
String name, String value, {HeaderEncoding encoding = HeaderEncoding.none}) → void -
Adds a header with the specified
name
andvalue
.inherited -
addMailAddressHeader(
String name, List< MailAddress> addresses) → void -
Adds another header with the specified
name
with the given mailaddresses
as its valueinherited -
addMessagePart(
MimeMessage mimeMessage, {ContentDisposition disposition = ContentDisposition.attachment}) → PartBuilder -
Adds the message
mimeData
as amessage/rfc822
content with the given subject as its filename.inherited -
addMultipartAlternative(
) → PartBuilder -
Adds a part with the
multipart/alternative
subtype.inherited -
addPart(
{ContentDispositionHeader? disposition, MimePart? mimePart, MediaSubtype? mediaSubtype, bool insert = false}) → PartBuilder -
Adds a new part
inherited
-
addRecipient(
MailAddress recipient, {RecipientGroup group = RecipientGroup.to}) → void -
Adds a
recipient
. -
addText(
String text, {MediaType? mediaType, TransferEncoding transferEncoding = TransferEncoding.automatic, CharacterSet characterSet = CharacterSet.utf8, ContentDispositionHeader? disposition, bool insert = false}) → PartBuilder -
Adds a text part to this message with the specified
text
.inherited -
addTextHtml(
String text, {TransferEncoding transferEncoding = TransferEncoding.automatic, CharacterSet characterSet = CharacterSet.utf8, ContentDispositionHeader? disposition, bool insert = false}) → PartBuilder -
Adds a HTML text part
inherited
-
addTextPlain(
String text, {TransferEncoding transferEncoding = TransferEncoding.automatic, CharacterSet characterSet = CharacterSet.utf8, ContentDispositionHeader? disposition, bool insert = false}) → PartBuilder -
Adds a plain text part
inherited
-
buildMimeMessage(
) → MimeMessage - Creates the mime message based on the previous input.
-
clearRecipients(
) → void - Removes all recipients from this message.
-
getPart(
MediaSubtype mediaSubtype, {bool recursive = true}) → PartBuilder? -
Retrieves the first builder with the specified
mediaSubtype
.inherited -
getTextHtmlPart(
) → PartBuilder? -
Retrieves the first builder with a text/plain part.
inherited
-
getTextPlainPart(
) → PartBuilder? -
Retrieves the first builder with a text/plain part.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeAttachment(
AttachmentInfo info) → void -
Removes the specified attachment
info
inherited -
removeHeader(
String name) → void -
Removes the header with the specified
name
.inherited -
removePart(
PartBuilder childBuilder) → void -
Removes the specified part
childBuilder
inherited -
removeReadReceiptRequest(
) → void - Removes the read receipt request.
-
removeRecipient(
MailAddress recipient) → void -
Removes the specified
recipient
from To/Cc/Bcc fields. -
requestReadReceipt(
{MailAddress? recipient}) → void -
Requests a read receipt by setting the
Disposition-Notification-To
header to from address. -
setContentType(
MediaType mediaType, {CharacterSet? characterSet, String? multiPartBoundary, String? name, Map< String, String> ? parameters}) → void -
Creates the content-type based on the specified
mediaType
.inherited -
setHeader(
String name, String? value, {HeaderEncoding encoding = HeaderEncoding.none}) → void -
Sets a header with the specified
name
andvalue
, replacing any previous header with the samename
.inherited -
setMailAddressHeader(
String name, List< MailAddress> addresses) → void -
Adds the header with the specified
name
with the given mailaddresses
as its valueinherited -
setRecommendedTextEncoding(
bool supports8BitMessages) → TransferEncoding -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
buildReadReceipt(
MimeMessage originalMessage, MailAddress finalRecipient, {String reportingUa = 'enough_mail', bool isAutomaticReport = false, String subject = 'read receipt', String textTemplate = MailConventions.defaultReadReceiptTemplate}) → MimeMessage -
Builds a disposition notification report for the given
originalMessage
that has been received by thefinalRecipient
. -
buildSimpleTextMessage(
MailAddress from, List< MailAddress> to, String text, {List<MailAddress> ? cc, List<MailAddress> ? bcc, String? subject, HeaderEncoding subjectEncoding = HeaderEncoding.Q, DateTime? date, MimeMessage? replyToMessage, bool replyToSimplifyReferences = false, String? messageId, bool isChat = false, String? chatGroupId, CharacterSet characterSet = CharacterSet.utf8, TransferEncoding transferEncoding = TransferEncoding.quotedPrintable}) → MimeMessage - Creates a text message.
-
createForwardSubject(
String originalSubject, {String defaultForwardAbbreviation = MailConventions.defaultForwardAbbreviation}) → String -
Creates a subject based on the
originalSubject
taking mail conventions into account. -
createMessageId(
String? hostName, {bool isChat = false, String? chatGroupId}) → String - Generates a message ID
-
createRandomId(
{int length = 18}) → String - Creates a new randomized ID text.
-
createReplySubject(
String originalSubject, {String defaultReplyAbbreviation = MailConventions.defaultReplyAbbreviation}) → String -
Creates a subject based on the
originalSubject
taking mail conventions into account. -
encodeHeaderValue(
String value, [TransferEncoding transferEncoding = TransferEncoding.quotedPrintable]) → String -
Encodes the specified header
value
. -
encodeText(
String text, TransferEncoding transferEncoding, [CharacterSet characterSet = CharacterSet.utf8]) → String -
Encodes the specified
text
with giventransferEncoding
. -
fillTemplate(
String template, MimeMessage message, {Map< String, String> ? parameters}) → String -
Fills the given
template
with values extracted from the providedmessage
. -
fromContentTransferEncodingName(
String name) → TransferEncoding -
getCharacterSetName(
CharacterSet? characterSet) → String -
Retrieves the name of the specified
characterSet
. -
getCodec(
CharacterSet? characterSet) → Codec -
Rerieves the codec for the specified
characterSet
. -
getContentTransferEncodingName(
TransferEncoding encoding) → String -
Retrieves the name of the specified
encoding
. -
prepareForwardMessage(
MimeMessage originalMessage, {MailAddress? from, String forwardHeaderTemplate = MailConventions.defaultForwardHeaderTemplate, String defaultForwardAbbreviation = MailConventions.defaultForwardAbbreviation, bool quoteMessage = true, HeaderEncoding subjectEncoding = HeaderEncoding.Q, bool forwardAttachments = true}) → MessageBuilder -
Prepares to forward the given
originalMessage
. Optionallyspecify the sending user withfrom
. You can also specify a customforwardHeaderTemplate
. The defaultMailConventions.defaultForwardHeaderTemplate
contains the metadata information about the original message including subject, to, cc, date. Specify thedefaultForwardAbbreviation
if notFwd
should be used at the beginning of the subject to indicate an reply. SetquoteMessage
tofalse
when you plan to quote text yourself, e.g. using theenough_mail_html
's packagequoteToHtml()
method. SetforwardAttachments
tofalse
when parts with a content-disposition of attachment should not be forwarded. -
prepareFromDraft(
MimeMessage draft) → MessageBuilder -
Prepares a message builder from the specified
draft
mime message. -
prepareMailtoBasedMessage(
Uri mailto, MailAddress from) → MessageBuilder -
Convenience method for creating a message based on a mailto URI from the sender specified in
from
. -
prepareMessageWithMediaType(
MediaSubtype subtype, {TransferEncoding transferEncoding = TransferEncoding.eightBit}) → MessageBuilder -
Convenience method for initiating a message with the specified media
subtype
-
prepareMultipartAlternativeMessage(
{TransferEncoding transferEncoding = TransferEncoding.eightBit}) → MessageBuilder - Convenience method for initiating a multipart/alternative message
-
prepareMultipartMixedMessage(
{TransferEncoding transferEncoding = TransferEncoding.eightBit}) → MessageBuilder - Convenience method for initiating a multipart/mixed message
-
prepareReplyToMessage(
MimeMessage originalMessage, MailAddress from, {bool replyAll = true, bool quoteOriginalText = false, bool preferPlainText = false, String replyHeaderTemplate = MailConventions.defaultReplyHeaderTemplate, String defaultReplyAbbreviation = MailConventions.defaultReplyAbbreviation, bool replyToSimplifyReferences = false, List< MailAddress> ? aliases, bool handlePlusAliases = false, HeaderEncoding subjectEncoding = HeaderEncoding.Q}) → MessageBuilder -
Prepares to create a reply to the given
originalMessage
to be send by the user specifed infrom
. -
quotePlainText(
String header, String? text) → String -
Quotes the given plain text
header
andtext
.