- To build a simple email.
MimeMessage message = JMail.builder()
.from("[email protected]")
.to("[email protected]")
.subject("Hello world!")
.text("Hello world!")
.build();- To build an HTML email.
MimeMessage message = JMail.builder()
.from("[email protected]")
.to("[email protected]")
.subject("Hello world!")
.html("<span style=\"color:#E53333;\">Hello world!</span>")
.build();- To build an email with Inline(picture inline)。
String cid = "123456";
MimeMessage message = JMail.builder()
.from("[email protected]")
.to("[email protected]")
.subject("Hello world!")
.text("Hello world!!")
.html("<span style=\"color:#E53333;\">Hello world!</span><img src=\"cid:" + cid + "\" alt=\"\" />")
.addInline(cid, new File("../jmail/picture.jpg"))
.build();- To build an email with attachment.
MimeMessage message = JMail.builder()
.from("[email protected]")
.to("[email protected]")
.subject("Hello world!")
.text("Hello world!")
.html("<span style=\"color:#E53333;\">Hello world!</span>")
.addAttachment(new File("../jmail/test.txt"))
.build();- To build an email with inline picture and attachment.
String cid = "123456";
MimeMessage message = JMail.builder()
.from("[email protected]")
.to("[email protected]")
.subject("Hello world!")
.text("Hello world!")
.html("<span style=\"color:#E53333;\">Hello world!</span><img src=\"cid:" + cid + "\" alt=\"\" />")
.addInline(cid, new File("../jmail/picture.jpg"))
.addAttachment(new File("../jmail/test.txt"))
.build();