nidhin
nidhin

Reputation: 6920

Create MimeMessage object using String content

How to create a MimeMessage object using String in java

MimeMultipart multiPart = new MimeMultipart();

and need to set content from a String Object

Upvotes: 2

Views: 2195

Answers (1)

Paulius Matulionis
Paulius Matulionis

Reputation: 23415

This code will do this:

MimeBodyPart messagePart = new MimeBodyPart();
MimeMultipart multipart = new MimeMultipart();

messagePart.setText("You message's string content goes here.", "utf-8");
multipart.addBodyPart(messagePart);

You have to create a MimeBodyPart object, then set all needed properties to it and add it to MimeMultipart.

Upvotes: 3

Related Questions