how to convert String to message in java mail api?
+2
A:
I'm not sure what you're after. Perhaps The Quintessential Program to Send E-Mail [J2EE] helps?
Key method being msg.setText(content)
.
aioobe
2010-06-01 11:51:34
+1
A:
If the String contains the message body, just take or create a Message object (like a MimeMessage
) and use the setText
method.
Otherwise, if the String holds a 'full' email, you'll have to separate header and body (from the String) and could use the addHeaderLine()
method to recreate a message header.
Andreas_D
2010-06-01 11:52:59
A:
You can use the MimeMessage
constructor which accepts an InputStream
. (See the JavaMail documentation)
Message msg = new MimeMessage(mySession,
new ByteArrayInputStream(myString.getBytes()));
DR
2010-06-01 11:57:24