mailcore2 : Mail Body contain image description

67 Views Asked by At

I am using mailcore2 for email in my app.

I am using the below code for the email load body but it also shows an image description with name. I want only message body without image name. Is there any option?

private fun loadBody() {
        mBodyOp = imapSession().plainTextBodyRenderingOperation(mImapMessage, mCurrentFolder.tag, true)
        mBodyOp?.start(object : ShortOperationCallback(context) {
            override fun succeeded() {
                vEmailText.text = mBodyOp?.result()
            }
        })
    } 
1

There are 1 best solutions below

0
Shweta Chauhan On

I didn't get any specific answer but somehow I managed it like below.I don't know it's proper or not.

First of all check attachments is available or not. After that split body with "-" sign and first attachment file name.So, it split with email body and all attachment.

private fun loadBody() {
        mBodyOp = imapSession().plainTextBodyRenderingOperation(mImapMessage, mCurrentFolder.tag, false)
        mBodyOp?.start(object : ShortOperationCallback(context) {
            override fun succeeded() {
                mImapMessage?.attachments()?.let {
                    if (it.isNotEmpty())
                        vEmailText.text = mBodyOp?.result()?.split("- "+ it[0].filename())?.get(0) ?: ""
                    else
                        vEmailText.text = mBodyOp?.result()
                }
            }
        })
    }