Note that there are some explanatory texts on larger screens.

plurals
  1. POArabic Content issue in reading mails using javamail API
    primarykey
    data
    text
    <p>I am using Javamail API to read mails from Gmail server. I am sending a mail with Arabic content from a gmail id to another Gmail id. The Charset encoding type of the mail is windows-1256. When i download the mail using Javamail I am getting content in "??????" format instead of Arabic Characters. I am converting the downloaded content to UTF-8 format but still not getting the proper display. </p> <p>Thanks in advance,</p> <p>Tim</p> <p><strong>Update:</strong><br> I am using the following code to fetch the content : </p> <pre><code>Object content = message.getContent(); if (message.isMimeType("text/html") || message.isMimeType("text/plain")) { Al = (String) content; } </code></pre> <p>Once content is downloaded, the following code is used for UTF-8 encoding: </p> <pre><code>byte[] utf8Bytes = s.getBytes("UTF-8"); s = new String(utf8Bytes, "UTF-8"); </code></pre> <p><strong>Update : Complete code that I am using for reading the mail contents at present</strong><br></p> <pre><code>String gmailMultipartMailDownload(Multipart multipart, String Uids) throws SocketException, UnsupportedDataTypeException, UnsupportedEncodingException { String Content = new String(""); try { int numParts = multipart.getCount(); for (int k = 0; k &lt; numParts; k++) { BodyPart bodyPart = multipart.getBodyPart(k); Object tmp = null; try { tmp = bodyPart.getContent(); } catch (UnsupportedDataTypeException UEE) { try { InputStream is = bodyPart.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; while ((line = br.readLine()) != null) { sb.append(line + "\n"); } br.close(); return sb.toString(); } catch (IOException e) { e.printStackTrace(); } catch (MessagingException e) { e.printStackTrace(); } } catch (UnsupportedEncodingException UEE) { UEE.printStackTrace(); try { InputStream is = bodyPart.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; while ((line = br.readLine()) != null) { sb.append(line + "\n"); } br.close(); return sb.toString(); } catch (IOException e) { e.printStackTrace(); } catch (MessagingException e) { e.printStackTrace(); } } String disposition = bodyPart.getDisposition(); if (tmp instanceof InputStream) { try{ if( super.Downloadfiles(bodyPart, hashCode, attnumcount,this.getgmailattachmentfolder())) { //Download Attachments } }catch (FileNotFoundException err) { return Content; } catch(IOException fex){ fex.printStackTrace(); return Content; } } else if (disposition != null &amp;&amp; (disposition.equals(BodyPart.ATTACHMENT) || disposition.equals(BodyPart.INLINE) || disposition.equals("ATTACHMENT"))) { try{ if( super.Downloadfiles(bodyPart, hashCode, attnumcount,this.getgmailattachmentfolder())) { //Download Attachments } }catch (FileNotFoundException err) { System.out.println(err.getMessage()); return Content; } catch(IOException fex){ fex.printStackTrace(); return Content;} } else if (bodyPart.isMimeType("multipart/*")) { Multipart mp = (Multipart) bodyPart.getContent(); Content += gmailMultipartMailDownload(mp, Uids); } else if (bodyPart.isMimeType("text/html")) { Content += bodyPart.getContent().toString(); } } } catch (Exception Ex) { System.out.println("Content object error is "+Ex); return Content; } finally { return Content; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload