How to get Formatted Mail Content through Java Application

I am using a mail sending function in my applet code which is listed below:
Main content is fetched from a format tool bar in JSP Page and it is passed as parameter to applet and it is used inside the mail content.
Same content when passed and executed in a JSP page, the formatted content is not lost and it is included in mail content as what it is fetched from Format Tool Bar.
Format is lost when it is used inside the Java Application mail sending function.
The below code I have used to send mail:
package com;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
class mailsendClass
public void sendmail(String from,String host,boolean debug,String msgText)
     try
          Set tomailsid = new HashSet();
          Set ccmailsid = new HashSet();
          //to mail ids           
          tomailsid.add("[email protected]" );          
          tomailsid.add("[email protected]" );
          tomailsid.add("[email protected]" );
          //cc mail ids
          ccmailsid.add("[email protected]" );
          ccmailsid.add("[email protected]" );
          String mailarray[]= (String[])tomailsid.toArray(new String[tomailsid.size()]);
          String ccmailID[]= (String[])ccmailsid.toArray(new String[ccmailsid.size()]);
          Properties props = new Properties();
          //props.put("mail.smtp.port","425");
          props.setProperty("mail.smtp.host", host);
          if (debug) props.setProperty("mail.debug", ""+debug);
          Session session = Session.getInstance(props, null);
          session.setDebug(debug);
          String mailsubject = "Mail Subject";
          // create a message
          Message msg = new MimeMessage(session);
          msg.setFrom(new InternetAddress(from));
          javax.mail.internet.InternetAddress[] toAddress=new javax.mail.internet.InternetAddress[mailarray.length];
          for (int i=0;i<mailarray.length ;i++ )
          toAddress=new javax.mail.internet.InternetAddress(mailarray[i]);
          System.out.println ("id inside to address loop " + i + " is "+ mailarray[i]);
          System.out.println ("toAddress " + i + " is "+ toAddress[i]);
          msg.setRecipients(Message.RecipientType.TO, toAddress);
          msg.setSubject(mailsubject);
          try
               javax.mail.internet.InternetAddress[] CCAddress=new javax.mail.internet.InternetAddress[ccmailID.length];
               for (int i=0;i<ccmailID.length ;i++ )
                    CCAddress[i]=new javax.mail.internet.InternetAddress(ccmailID[i]);
                    System.out.println("CC Array is ===> " +CCAddress[i] );//          
          msg.setRecipients(Message.RecipientType.CC,CCAddress);
          catch(Exception ss)
               System.out.println("CC mail Exception is ====>"+ ss);     
               msg.setSentDate(new java.util.Date());
//          Multipart multipart = new MimeMultipart("relative");
               Multipart multipart = new MimeMultipart("alternative");
          BodyPart messageBodyPart = new MimeBodyPart();
          messageBodyPart.setContent(msgText, "text/html");
//          messageBodyPart.setContent(msgText, "text/plain");
          multipart.addBodyPart(messageBodyPart);          
               msg.setContent(multipart);
          Transport.send( msg );
     catch (Exception e)
          System.out.println("The Exception is ------>"+e);
public class SendMail {
public static void main(String[] args)
     System.out.println("before Mail Send ");
     mailsendClass mail = new mailsendClass();
     String from="[email protected]";
     String host="172.16.2.6";
     String msgText="<p><strong>Index</strong><br />I have posted the following PDFs (Second Pages) as mentioned to start producing the Index:<br />• Engage<br />• Chapters 1–6<br /><a title='ftp:///Index' href='ftp://index/'>ftp:///Index</a><strong><br />XML Coding - Files with errors</strong><br />• Engage<br />• Chapters 1–6<br /><a title='ftp:///XML_Coding_Need%20Fixing' href='ftp://xml_coding_need%20fixing/'>ftp:///XML_Coding_Need%20Fixing</a></p>";
     mail.sendmail(from,host,true,msgText);
     System.out.println("after Mail Send ");
Content placed in format tool bar is as follows:
Index
I have posted the following PDFs (Second Pages) as mentioned to start producing the Index:
• Engage
• Chapters 1–6
ftp:///Index
XML Coding - Files with errors
• Engage
• Chapters 1–6
ftp:///XML_Coding_Need%20Fixing
Content fetched from format tool bar inside JSP page is as follows:
<p><strong>Index</strong>
I have posted the following PDFs (Second Pages) as mentioned to start producing the Index:
&bull; Engage
&bull; Chapters 1&ndash;6
<a title="ftp:///Index" href="ftp://index/">ftp:///Index</a><strong>
XML Coding - Files with errors</strong>
&bull; Engage
&bull; Chapters 1&ndash;6
<a title="ftp:///XML_Coding_Need%20Fixing" href="ftp://xml_coding_need%20fixing/">ftp:///XML_Coding_Need%20Fixing</a></p>
Fetched Content inside Java Application through parameter and it will use as input for mail content is as follows:
<p><strong>Index</strong>
I have posted the following PDFs (Second Pages) as mentioned to start producing the Index:
• Engage
• Chapters 1–6
<a title="ftp:///Index" href="ftp://index/">ftp:///Index</a><strong>
XML Coding - Files with errors</strong>
• Engage
• Chapters 1–6
<a title="ftp:///XML_Coding_Need%20Fixing" href="ftp://xml_coding_need%20fixing/">ftp:///XML_Coding_Need%20Fixing</a></p>
Actual mail received after Java Application execution is as follows:
Index
I have posted the following PDFs (Second Pages) as mentioned to start producing the Index:
? Engage
? Chapters 1?6
ftp:///Index
XML Coding - Files with errors
? Engage
? Chapters 1?6
ftp:///XML_Coding_Need%20Fixing
Unicode characters in the mail content are replaced by “?”.
In the function listed above I have used the MIME Setting as
Multipart multipart = new MimeMultipart("alternative");
I have tried by using “relative” MIME format also as
Multipart multipart = new MimeMultipart("relative");
But I am not getting the actual format passed as input to the Java Application in the mail content.
Can anybody let us know how to overcome this problem?
Thanks in advance.

You need to really understand how the different multiparts work instead of just guessing.
But for your application, you don't need a multipart at all. Just use msg.setText(msgText, null, "html");
Although that doesn't explain your problem, it will simplify your program.
How are you determining that the mail received doesn't have the formatting? Are you viewing it in a
mail reader (e.g., Outlook)? Or are you fetching it with JavaMail?
Are you using an Exchange server? Exchange will often reformat your message to what it thinks you meant.

Similar Messages

  • How to get Sharepoint OAuth clientId for Java application used in any tenant

    I'm developing a web application for Office365 using the SharePoint 2013 REST service.
    This app is hosted by my web server. The development language is Java.
    I plan that users in any tenant use my app via OAuth.
    How can I register my app to get clientId for OAuth?
    I attempted to register my app by seller dashboard, but it seemed like register applications
    to seller dashboard should be developed by .NET. And I couldn't use appregnew.aspx
    because cilentId from appregnew.aspx could use only in one tenant.
    Please let me know any better way to register my app.
    Thanks,
    Tarou

    Hi,
    SharePoint 2013 provide three types of app, SharePoint-hosted app, Provider-hosted app and Autohosted app. Which one do you used?
    Here is an article from MSDN for your reference:
    Guidelines for registering apps for SharePoint 2013
    http://msdn.microsoft.com/en-us/library/office/jj687469(v=office.15).aspx
    Best Regards
    Dennis Guo
    TechNet Community Support

  • How to get the source code of Java Concurrent Program?

    Hi,
    How to get the source code of Java Concurrent Program?
    Example
    Programe Name:Format Payment Instructions
    Executable:Format Payment Instructions
    Execution File Name:FDExtractAndFormatting
    Execution File Path:oracle.apps.iby.scheduler
    Thanks in advance,
    Senthil

    Go on Unix box at $JAVA_TOP/oracle/apps/iby/scheduler
    You will get class file FDExtractAndFormatting.
    Decompile it to get source code.
    Thanks, Avaneesh

  • How to get(copy) the contents i.e the cell of an excel sheet to other excel

    How to get(copy) the contents i.e the cells of an excel sheet to another excel sheet.
    I can read the contents i.e the text in the cells and able to display it in the Java console
    i want these contents to be copied to another excel sheet with the cells data.
    I am using Java Swing for the UI, POI framework for the excel work.
    Please anyone suggest some code to this requirement.

    [spreadsheets with poi|http://poi.apache.org/spreadsheet/converting.html] Hi
    on the poi apache site there's a number of good examples...
    I started with poi only a week ago, but just from reading these examples
    (especially SS Usermodel code) i managed all i needed to know (so far).
    kind regards
    BB
    Edited by: BugBunny on Feb 22, 2010 4:36 AM

  • How to get af:commandbutton id in java code when it is triggered?

    Hi All
    In my application's homepage, I am using 2 af:commandbuttons and each using action attribute to call a method. Both are calling the same method, and based on its id, it should perform different operations. Could anyone please tell me how to get command buttons id in java code, when it is triggered.
    Regards
    Venkat

    Venkat,
    why not call different methods from each button?
    public String actionButton1()
    return doAction("button1");
    public String actionButton2()
    return doAction("button2");
    public String doAction(String aBuuton)
    if ("button1".equalsIgnoreCase(aButton))
    // do work for button 1
    return "abc";
    }else {
    // do work for button 2
    return "abc";
    }Now you user actionbutton1 for the first button and actionButton2 for the second.
    Or you directly implement two different methods in the bean and call each one directly from the button.
    Timo

  • How to get the current path of my application in java ?

    how to get the current path of my application in java ?
    thanks

    To get the path where your application has been installed you have to do the following:
    have a class called "what_ever" in the folder.
    then you do a litte:
    String path=
    what_ever.class.getRessource("what_ever.class").toString()
    That get you a string like:
    file:/C:/Program Files/Cool_program/what_ever.class
    Then you process the result a little to remove anything you don't want:
    path=path.substring(path.indexOf('/')+1),path.lastIndexOf('/'))
    //Might be a little error here but you should find out //quickly if it's the case
    And here you go, you have a nice
    C:/Program Files/Cool_program
    which is the path to your application.
    Hooray

  • How to get yahoo mail in notification in macbook pro in mountain lion os

    how to get yahoo mail in notification in macbook pro in mountain lion os??

    Are you using the web interface? You must add your Yahoo! Mail account to mail.app to get notifications.

  • How to get the context data using java script in interactive forms

    Hi All,
    How to get the context data using java script in interactive forms by adobe,  am using web dynpro java
    thanks.

    Hi venkat,
    Please Refer this link.
      Populating one Drop-Down list from the selection of another Drop-down list
    Thanks,
    Raju.

  • How to get Alerts mail for adapter engine errors in SAP PI 7.0

    Hi Friends,
    I configured Alerts in PI 7.0. with the help of t-code u2018ALRTCATDEF and created a new alert catergory.
    In container tab i have mentioned all give below elements.
    SXMS_MSG_GUID, SXMS_RULE_NAME, SXMS_ERROR_CAT, SXMS_ERROR_CODE, SXMS_FROM_PARTY, SXMS_FROM_SERVICE, SXMS_FROM_NAMESPACE, SXMS_FROM_INTERFACE, SXMS_TO_PARTY, SXMS_TO_SERVICE, SXMS_TO_NAMESPACE,SXMS_TO_INTERFACE
    I am getting alerts when I manually test the alerts configurations by running the report u2018RSALERTTESTu2019.
    I am getting mail as :
    Alert ID: ##00009##
    Dear Administrator,
    This is with respect to XI Scenario. During processing of XML file from ECC or XYZ Server, Following error has been occured:
    Message ID:
    Interface:
    NOTE: To check the file name, go to SXMB_MONI and search for above message ID.
    Double click on that message ID and click on error in left hand tree.
    Please take appropriate action in co-ordination with respective functional and BASIS consultant.
    But When I am getting a error , I am not getting an alert mail. Right now iam doing in XI Development.
    I am not getting an Alert mail , when my message is in status of : System Error . Error catergory is : XI_J2EE_ADAPTER_JDBC.
    Kindly tell how to get alert mail for error catergory : XI_J2EE_ADAPTER_JDBC and in Adapter engine errors.
    How to get alert mail when my message is failed with any reason in Adapter engine.
    Waiting for quick replay. Please help me out.
    Regards,
    Ahmed.

    Hi thanks for quick reply.
    As per your given link : http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/14877. [original link is broken]
    I have done all these steps. But still little problem.
    as per link he is getting Error  description , error message id , alert rule..
    In my case I am not getting these information. when my messages failed. When I am doing manully testing the alert getting an mail as :
    Alert ID: ##00009##
    Dear Administrator,
    This is with respect to XI Scenario. During processing of XML file from ECC or XYZ Server, Following error has been occured:
    Message ID:
    Interface:
    NOTE: To check the file name, go to SXMB_MONI and search for above message ID.
    Double click on that message ID and click on error in left hand tree.
    Please take appropriate action in co-ordination with respective functional and BASIS consultant.
    Is it okay the body of mail??.
    I am not getting alert mail when my messages failed in adapter engine and Integration Engine.
    Ex my message is failed in AE:as below.
    My messages flow as : SAP --> XI --> DB.
    Messages is success (in ECC moni)> XI moni also success> XI Adapter engine getting error as (Status: System Error) and (Error Category : XI_J2EE_ADAPTER_JDBC).
    Regards,
    Ahmed.

  • Does anyone know how to get apple mail in Lion to connect with Exchange 2007?

    Does anyone know how to get apple mail in Lion 10.7.2 to connect with Exchange 2007?  It worked perfectly with Snow Leopard... upgraded to lion and it won't work.  We use Exchange 2007 with SP 3 and Rollup 4.  Won't connect... and I can't get Apple to give me any direction. 

    We finally got it to work today.  We had to call and pay for the microsoft support service, but the issue was on the server end.  We had to go into the iis manager... went to sites... when to default website...and changed the SSL settings for Auto Discover, EWS Exadmin, echange, exchweb, owa... and the rest..
    Change the settings to ignore client certificates.
    Problem solved. Can finally send and receive.

  • How to get the form printed through the transaction ME42

    hi,
    How to get the form printed through the transaction ME42.
    For example :
    In t.code vf03 . In the main menu there is an option billing document , when we click on that we get a drop down menu which shows issue output to. If a print program call has the code to get the value from the t.code , immdiately when we click issue output to it call the form.

    Here go to ME42 put in your RFC no, in the menu Header -- Messages, go there and see if a message has been inserted, else you can insert one.
    when you save this, it will call the form.
    Regards,
    Ravi

  • TS2755 How do get my mail on my ipad 3 to set the same email rules as is on my imac ???

    How do get my mail on my ipad 3 to set the same email rules as is on my imac ???

    Setting up and troubleshooting Mail
    http://www.apple.com/support/ipad/assistant/mail/
    iPad Mail
    http://www.apple.com/support/ipad/mail/
     Cheers, Tom

  • Urgent!!! How to convert received mail 'content type?

    How to convert received mails 'content type from text/plain to multipart/*?

    you cannot change the content type of a Message object which has been received. What you can do is create an instance of a MimeMessage class and set the content type as multipart and then add the received message as a bodypart to that message.
    You can look at the javamail example codes as to how to create a new MimeMessage with multipart content.
    anurag

  • How to modify the mail content in Spaces

    How can the default mail content dispatched from "Send Email" in Discussion Forum can be modified ? Please can someone guide on how this can be achieved?
    I need to modify the subject of the message being broadcasted to the Space members.
    Version WebCenter Spaces PS4 (no cutomizations have been done)

    Hi,
    Do you mean to read the mail content in R/3 inbox or UWL..?
    If in R/3 then SBWP transaction Unread Documents..
    If in UWL see notifications part.
    Please if this does not solve your problem> please elaborate on your problem
    Regards
    Sai

  • How to create an Oracle DATABASE through Java Programming Language.. ?

    How to create an Oracle DATABASE through Java Programming Language.. ?

    Oracle database administrators tend to be control freaks, especially in financial institutions where security is paramount.
    In general, they will supply you with a database, but require you to supply all the DDL scripts to create tables, indexes, views etc.
    So a certain amount of manual installation will always be required.
    Typically you would supply the SQL scripts, and a detailled installation document too.
    regards,
    Owen

Maybe you are looking for

  • Adobe Reader XI 'Save As' creating blank pdfs

    Hi All, I am using an application from which a report is generated as a PDF file using Component One - VSReport, VSPrinter and VSPDF. This report PDF is automatically created in a shared folder and it is displayed once it is created. I can do 'Save A

  • SideBySide errors after new acrobat 9 pro install

    hello, i am building a clean install of windows 7 pro 64-bit on my laptop.  after installing acrobat 9 pro, i now get several errors in the event viewer: Activation context generation failed for "C:\Program Files (x86)\Adobe\Acrobat 9.0\Designer 8.2\

  • UITableView with custom frame size within a UINavigationController... how?

    I've seen similar questions asked all over the web, but so far not a single "real" answer has cropped up, so hopefully you folks will know the way to do this. I have a main view that with a UIView subview, inside of which I am programmatically adding

  • Burn itunes movie to dvd

    I purchased a few movies and want to burn them to a dvd.  How can I do this?  Apple seems to make this very difficult to do.

  • How to know default JRE from registry

    Hi What could be the way to know the default JRE being used by the browser. I mean if I have installed jre 1.3.1 and jre 1.4.1. and in control panel I set 1.3.1 as the jre to be used by the browser. I want to know through my program that which is the