quoteToHtml method
Quotes the body of this message for editing HTML.
Optionally specify the quoteHeaderTemplate
, defaults to
MailConventions.defaultReplyHeaderTemplate
, for forwarding you
can use the MailConventions.defaultForwardHeaderTemplate
.
Set blockExternalImages
to true
in case external images
should be blocked.
Set preferPlainText
to true
to use plain text instead of the
HTML text.
Set enableDarkMode
to true
to enforce dark mode on devices
with older browsers.
Optionally specify the maxImageWidth
to set the maximum width
for embedded images.
Optionally specify the emptyMessageText
for messages that contain
no other content.
Optionally specify the transformConfiguration
to control all aspects
of the transformation - in that case other parameters are ignored.
Implementation
String quoteToHtml({
String? quoteHeaderTemplate,
bool preferPlainText = false,
bool blockExternalImages = false,
bool enableDarkMode = false,
int? maxImageWidth,
String? emptyMessageText,
TransformConfiguration? transformConfiguration,
}) {
quoteHeaderTemplate ??= MailConventions.defaultReplyHeaderTemplate;
final quoteHeader = MessageBuilder.fillTemplate(quoteHeaderTemplate, this)
.replaceAll('&', '&')
.replaceAll('>', '>')
.replaceAll('<', '<')
.replaceAll('"', '"')
.replaceAll('\r\n', '<br/>');
final document = transformToDocument(
blockExternalImages: blockExternalImages,
preferPlainText: preferPlainText,
enableDarkMode: enableDarkMode,
maxImageWidth: maxImageWidth,
emptyMessageText: emptyMessageText,
transformConfiguration: transformConfiguration,
);
return '<p><br/></p><blockquote>$quoteHeader<br/>${document.body?.innerHtml}</blockquote>';
}