"how to fetch email and get there body content in spring boot" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "how to fetch email and get there body content in spring boot" answered properly. Developers are finding an appropriate answer about how to fetch email and get there body content in spring boot related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like how to fetch email and get there body content in spring boot. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on how to fetch email and get there body content in spring boot.
how to fetch email and get there body content in spring boot
@Throws(IOException::class, MessagingException::class)
private fun getTextFromMessage(message: Message): String {
var result: String = ""
if (message.isMimeType("text/plain")) {
result = message.content.toString()
}
else if (message.isMimeType("multipart/*")) {
val mimeMultipart =
message.content as MimeMultipart
result = getTextFromMimeMultipart(mimeMultipart)
}
else if(message.isMimeType("text/html")){
result = message.content.toString()
}
return result
}
@Throws(IOException::class, MessagingException::class)
private fun getTextFromMimeMultipart(
mimeMultipart: MimeMultipart
): String {
val count = mimeMultipart.count
if (count == 0) throw MessagingException("Multipart with no body parts not supported.")
val multipartRelated = ContentType(mimeMultipart.contentType).match("multipart/related")
if(multipartRelated){
val part = mimeMultipart.getBodyPart(0)
val multipartAlt = ContentType(part.contentType).match("multipart/alternative")
if(multipartAlt) {
return getTextFromMimeMultipart(part.content as MimeMultipart)
}
}else{
val multipartAlt = ContentType(mimeMultipart.contentType).match("multipart/alternative")
if (multipartAlt) {
for (i in 0 until count) {
val part = mimeMultipart.getBodyPart(i)
if (part.isMimeType("text/html")) {
return getTextFromBodyPart(part)
}
}
}
}
var result: String = ""
for (i in 0 until count) {
val bodyPart = mimeMultipart.getBodyPart(i)
result += getTextFromBodyPart(bodyPart)
}
return result
}
@Throws(IOException::class, MessagingException::class)
private fun getTextFromBodyPart(
bodyPart: BodyPart
): String {
var result: String = ""
if (bodyPart.isMimeType("text/plain")) {
result = bodyPart.content as String
} else if (bodyPart.isMimeType("text/html")) {
val html = bodyPart.content as String
result = html
} else if (bodyPart.content is MimeMultipart) {
result =
getTextFromMimeMultipart(bodyPart.content as MimeMultipart)
}
return result
}
Source: stackoverflow.com
All those coders who are working on the Whatever based application and are stuck on how to fetch email and get there body content in spring boot can get a collection of related answers to their query. Programmers need to enter their query on how to fetch email and get there body content in spring boot related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about how to fetch email and get there body content in spring boot for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of how to fetch email and get there body content in spring boot while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "how to fetch email and get there body content in spring boot". Visit this developer's friendly online web community, CodeProZone, and get your queries like how to fetch email and get there body content in spring boot resolved professionally and stay updated to the latest Whatever updates.