Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8354259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:29:52+00:00 2026-06-09T09:29:52+00:00

*I am working on an application which can read emails. I am using textview

  • 0

*I am working on an application which can read emails. I am using textview / edittext to display the mails. Right now I am able to fetch the email content as string and display it.
But Which is the best view to display emails with html content and images??
Please help me out.
Thank you 🙂
Edited:
I used webview as suggested by S.O. friends(thanks to @Andro Selva, @CFlex).
But I am facing a problem, Its displaying the email’s body twice! 🙁
Once as a text/plain and again as a Text/html.
its a screeshot of webview loaded with email message when a blank mail is sent
I have tried following codes to load webview.

webViewBody.loadData(details[3], "text/html", "UTF-8");
//webViewBody.loadDataWithBaseURL(null, details[3] , "text/html", "utf-8", null);

here details[3] is the email content.
What am i missing here!? 🙁 Please help me out.

EDITED:
I have Added codes I have Used to get the message contents for displaying email content below.

    public void getContent(Message msg)
{
     try
     {
        Object o = msg.getContent();
            if (o instanceof String) 
        {
        if(((String) o).equalsIgnoreCase(""))
        {
        }
                    else
        {
           messageBody = (String)o+"STRING!!";
        }
       }
       else if (o instanceof Multipart) 
       {
        Multipart mp = (Multipart)o;
            int count3 = mp.getCount();
        for (int j = 0; j < count3-1; j++)
        {
            // Part are numbered starting at 0
            BodyPart b = mp.getBodyPart(j);
            Object o2 = b.getContent();
            if (o2 instanceof String) 
            {
                if(((String) o).equalsIgnoreCase(""))
                {
                }
                                    else
                {
                    messageBody = (String)o2+"MULTIPART!!"; 
                }
            }
        } //End of for
       }
       else if (o instanceof InputStream) 
       {
        //System.out.println("**This is an InputStream message**");
        InputStream is = (InputStream)o;
        // Assumes character content (not binary images)
                    //messageBody = convertStreamToString(is)+"INPUT STREAM!!";
            int c;
                    while ((c = is.read()) != -1) 
                    {
                    messageBody = convertToString(is)+"INPUT STREAM!!";
                System.out.println(messageBody);
                    }
       }
    }
        catch (Exception ex)
    {
    System.out.println("Exception arise at get Content");
    ex.printStackTrace();
    }

    //TODO TEST CODES
    try
    {
        String contentType = msg.getContentType();
        //          System.out.println("Content Type : " + contentType);
        Multipart mp = (Multipart) msg.getContent();
        int count = mp.getCount();
        for (int i = 0; i < count; i++)
        {
            dumpPart(mp.getBodyPart(i));
        }
    }
    catch (Exception ex)
    {
        System.out.println("Exception arise at get Content");
        ex.printStackTrace();
    }
}

public String convertToString(InputStream inputStream)
{
    StringBuffer string = new StringBuffer();
    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
    String line;
    try 
    {
        while ((line = reader.readLine()) != null) 
        {
            string.append(line + "\n");
        }
    }
    catch (IOException e) 
    {
    }
    return string.toString();
}   

The control is always going to “else if (o instanceof InputStream)” condition. so its streaming email always and displaying complete email content. What am I missing here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:29:53+00:00Added an answer on June 9, 2026 at 9:29 am

    adding these lines solved the problem!

        MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
        mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
        mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
        mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
        mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
        mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
        CommandMap.setDefaultCommandMap(mc);
    

    Thanks to everyone who helped me to solve this. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an android application which can be used to capture the
These days I'm working on a VB.NET application which can be used to edit,
I am working on an application which fetch the location details in a periodic
I'm working on an Android application which can make internet phone calls. I got
I am working on an application that can read pdf documents and I am
I'm working on application which has workflow like this: 1.parsing home page (using HttpURLConnection,
I am working on iphone application which will read the following youtube page source:
I am working on an application in which, i have to read XML files
I'm working on a web application which needs to clear expired cache elements now
Right now, I am having application which works with WiFi, but while I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.