Android Question Merging text and image into Msg.Body?

William Hunter

Active Member
Licensed User
Longtime User
I am dealing with an email message having a content-type of text/plain. The text portion is quoted-printable, and there is an inserted image as a base64 image string. Both have been saved as attachments, and have been decoded appropriately.

I now have a text file for the text string, and a bmp file for the image. How do I merge these two files into Msg.Body for display in a WebView? Also, in the event there were more than one image, how would this be handled? Any help greatly appreciated.

Best regards :)
 

William Hunter

Active Member
Licensed User
Longtime User
Are you sending the mails to your app? If so then you can create a html body and include the images as base64 strings inside the html.
Thank you Erel. I have no role in the preparation of these messages. They are incoming from a mail server, and have been sent to me by third parties.

Best regards :)
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
How are the bitmaps referenced from the text?
Both the text and the image were downloaded as attachments. I have two individual files.

1. The text was quoted-printable and has been decoded to utf-8.

2. The image was a base64 image string and has been decoded to a bmp file.

As it stands now the image is not in any way referenced from the text. I simply extracted the two parts from the incoming raw message. It has had no other handling. I am looking for a way to merge the text and image so the compete original message can be displayed in a WebView. I'm doing some experimentation, so this might not be the right approach. I would like to find a way to display the text, and whatever number of images accompanied the text, into a WebView.

Regards :)
 
Upvote 0

William Hunter

Active Member
Licensed User
Longtime User
You can save the bitmaps in File.DirInternal and then reference them with:
B4X:
Dim html As String = $"

<p>text</p>
<img src='file://${File.Combine(File.DirInternal, "yourimage.jpg")}'/>
<p>more text</p>
"$
Thank you Erel. Is it possible to source the bitmap from a local variable, rather than File.DirInternal?

Regards :)
 
Upvote 0
Top