enough_mail_html 0.1.1 copy "enough_mail_html: ^0.1.1" to clipboard
enough_mail_html: ^0.1.1 copied to clipboard

outdated

Generate HTML from an email mime message. Eases handling of `MimeMessage` in the `enough_mail` package.

example/enough_mail_html_example.dart

import 'package:enough_mail/enough_mail.dart';
import 'package:enough_mail_html/enough_mail_html.dart';
import 'package:html/dom.dart';

String simpleTransformExample(MimeMessage mimeMessage) {
  return mimeMessage.transformToHtml();
}

String configureImageBlockingOrEmptyMessage(MimeMessage mimeMessage) {
  return mimeMessage.transformToHtml(
      blockExternalImages: true, emptyMessageText: 'Nothing here, move on!');
}

String playYourself(MimeMessage mimeMessage) {
  final cfg = TransformConfiguration.create(
      blockExternalImages: true,
      emptyMessageText: 'Nothing here, move on!',
      customDomTransformers: [StyleTextDomTransformer()],
      customValues: {'textStyle': 'font-size:10px;font-family:verdana;'});
  return mimeMessage.transformToHtml(transformConfiguration: cfg);
}

class StyleTextDomTransformer extends DomTransformer {
  @override
  void process(Document document, MimeMessage message,
      TransformConfiguration configuration) {
    final paragraphs = document.getElementsByTagName('p');
    for (final paragraph in paragraphs) {
      paragraph.attributes['style'] = configuration.customValues['textStyle'];
    }
  }
}
4
likes
0
pub points
78%
popularity

Publisher

verified publisherenough.de

Generate HTML from an email mime message. Eases handling of `MimeMessage` in the `enough_mail` package.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

enough_mail, html

More

Packages that depend on enough_mail_html