Sending HTML E Mail using Java Mail

Can anybody please tell me how to send HTML email using JavaMail. I know I need the DataContentHandler for text/html mime type but where can I find one? If anybody has better suggestions you are welcome.

Folks,
I've used what you have suggested. Though it compiled, I kept getting this java error
--Exception in MailServer.java
javax.mail.SendFailedException: Sending failed;
nested exception is:
javax.mail.MessagingException: IOException while sending message;nested exception is:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/html
at javax.mail.Transport.send0(Transport.java:204)
at javax.mail.Transport.send(Transport.java:73)
at MailTest.send(MailTest.java:419)
at MailTest.sendThruDefaultServer(MailTest.java:319)
at MailTest.main(MailTest.java:476)
[sendEmail() - Exception  :javax.activation.UnsupportedDataTypeException
HELP!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • How to send HTML Format Mail using Java Mail in oracle 9i Forms

    Dear All
    could you please tell me how to send HTML Format Mail using Java Mail in oracle 9i Forms and how to implement the java mail ?
    if it is possible, could you please send me the sample code? please very urgent
    Thanks
    P.Sivaraman

    Hello,
    <p>Here is a Form sample.</p>
    Francois

  • How do I  Send HTML formatted email  using  class in  javax.mail pkg

    How do I Send HTML formatted email using javax.mail pkg class ?i mean is thr any class available in this package to do this ?

    Please see
    http://javaalmanac.com/egs/javax.mail/SendApp.html
    for Quintessential Program to Send E-Mail.
    Then substitute line
    msg.setText(content);
    /with this one
    msg.setContent( content , "text/html");
    it should do in simplest form.

  • Help needed  while exporting crystal reports to HTML file format using java

    Help needed  while exporting crystal reports to HTML file format using java api(not using crystalviewer).i want to download the
    html file of the report
    thanks

    the ReportExportFormat class does not have HTML format, it has got to be XML. Export to HTML is available from CR Designer only.
    Edited by: Aasavari Bhave on Jan 24, 2012 11:37 AM

  • Can any one please send me sample programs using java mapping..

    <b>Can any one please send me sample programs using java mapping with input and output?</b>
    please let me know how to get started with java mapping?
    Prerequisites for java mapping ?
    What are the jars need to be deployed for SAX,DOM.  And how to do it in NWDS?
    Use of Execute() and setparameter() ... StreamTransformation?
    Some sample program using java mapping with simple logic(input and output)?

    Hi,
    Did you go thro these blogs?
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-iii
    Nice blogs to start Java Mapping.
    Go thro this one too.
    /people/stefan.grube/blog/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio
    Regards,
    P.Venkat
    Message was edited by:
            Venkataramanan

  • Want to send PDF as attachement using Java Mail

    HI,
    I am using Java mail API for sending PDF as attachment. Here is my sample code
    messageBodyPart = new MimeBodyPart();
    messageBodyPart.setDataHandler(new DataHandler("String data for PDF using iText", "text/plain" ));
    I am generating String for PDF file using iTEXT but I am unable to find out mimetype for passing into DataHandler as second paramete.
    Any idea?
    Thanks
    Shailesh

    Don't convert the data to String. It isn't text so
    you'll damage the binary content by doing that. In
    the "demos" directory of your JavaMail download
    you'll find a ByteArrayDataSource class you can use
    instead of a FileDataSource. Yes, this worked for me. I create the pdf in memory as as StringBuffer and I just changed the code from
    messageBodyPart.setDataHandler(new DataHandler(pdf.toString(), "application/pdf"));
    to
    messageBodyPart.setDataHandler(new DataHandler(new ByteArrayDataSource(pdf.toString(), "application/pdf")));
    and it worked.
    Thanks a lot for your help,
    Dennis

  • Sending html with Mail

    Is there any way to get Mail to send html code?

    Hello Colin Rose!
    I'm not quite sure if I get it right: do you want to know how to send html-emails with Apple Mail?
    If so, open up preferences, choose tab "Compose" and choose as format of your email "formatted text" or something like that (I am using German as my system-language, so I can only guess at the exact English designations). That should do the trick.
    floba

  • How to send a string from sender to receiver side using java

    I am doing a project on Digital Signature.I have already done with the GUI using java swing.
    Now i want to send a string from the sender side to the receiver side on the click of a button using socket programming.
    Please can anybody provide me with the code as early as possible.

    http://catb.org/~esr/faqs/smart-questions.html

  • How to SEND HTML formatted mail??

    How do I put HTML formatted text into an email I want to SEND? -- "Paste as HTML" in edit menu is dimmed, and I can't get it to un-dim... I want to paste formatted text from an HTML editor into an email... can I do this with Mail, or do I need some other app to do this?

    AHHHH
    What you can do to make HTML for Apple Mail is to make it in an HTML editor, open it with Safari use CMD+i - a new mail message will appear in a moment with the web page in the email body.
    You can't do any major editing in Mail, you'll have to go back to the HTML file. But it works.
    You can also use Copy (from a web page) and then (Edit) Paste as HTML (that what Paste as HTML is for, not for creating HTML email). You can also user Paste as HTML to copy/paste a HTML email you receive or part of a HTML email.

  • Error when sending HTML format mail from Oracle 9i forms

    Dear All,
    i have created one procedure with 15 in parameter by which i can send mail in HTML format. due to length problem i am using 15 parameter, every parameter has length 32767, i am splitting HTML coding after every parameter length fulfilled
    when 3 or 4 parameter only fulfilled mail comes well, but more than 4 parameter fulfilled mail is not coming, will any one of you kindly please help me to resolve this
    following procedure i am using.......
    PROCEDURE P_SEND_MAIL( subject_p varchar2, salutation_p varchar2, plan_hdr_msg_p varchar2,
    plan_dtl_msg_p_1 varchar2, plan_dtl_msg_p_2 varchar2, plan_dtl_msg_p_3 varchar2, plan_dtl_msg_p_4 varchar2,
    plan_dtl_msg_p_5 varchar2, plan_dtl_msg_p_6 varchar2, plan_dtl_msg_p_7 varchar2, plan_dtl_msg_p_8 varchar2,
    plan_dtl_msg_p_9 varchar2, plan_dtl_msg_p_10 varchar2, plan_dtl_msg_p_11 varchar2, plan_dtl_msg_p_12 varchar2,
    plan_dtl_msg_p_13 varchar2, plan_dtl_msg_p_14 varchar2, plan_dtl_msg_p_15 varchar2, summary_p varchar2,
    cmplmntry_sign_msg_p varchar2, mailto_p varchar2 ) IS
    mail_from varchar2(100);
         mailhost varchar2(30) := 'MAIL-SRVR';
         crlf varchar2(10) := CHR(13)||CHR(10);
         mess_bdy varchar2(10000);
         Port number := 25;
         conn UTL_SMTP.CONNECTION;
    begin
         mail_from := 'IT-Department';
         mess_bdy := 'Date: ' ||TO_CHAR( SYSDATE, 'dd Mon yy hh24:mi:ss' )|| crlf ||
         'From:' ||mail_from|| crlf ||
         'Subject:'||subject_p|| crlf ||
         'To: ' ||mailto_P|| crlf ||'' || crlf;
         conn:= utl_smtp.open_connection( mailhost, Port );
         utl_smtp.helo( conn, mailhost );
         utl_smtp.mail( conn, mail_from);
         utl_smtp.rcpt( conn, mailto_P );
         utl_smtp.data( conn, 'MIME-Version: 1.0' ||CHR(13)|| CHR(10)||
         'Content-type: text/html' || CHR(13)||CHR(10)||
         mess_bdy||salutation_p||plan_hdr_msg_p
         ||plan_dtl_msg_p_1||plan_dtl_msg_p_2||plan_dtl_msg_p_3||plan_dtl_msg_p_4||plan_dtl_msg_p_5
         ||plan_dtl_msg_p_6||plan_dtl_msg_p_7||plan_dtl_msg_p_8||plan_dtl_msg_p_9||plan_dtl_msg_p_10
         ||plan_dtl_msg_p_11||plan_dtl_msg_p_12||plan_dtl_msg_p_13||plan_dtl_msg_p_14||plan_dtl_msg_p_15
         ||summary_p||cmplmntry_sign_msg_p);
         utl_smtp.quit( conn );
    exception
         when others then
         null;
    END;

    did u encounter any error?
    Be more clear in ur saying. As i understood that - is when coming to 5th parameter u r not able to access it. Is it right?
    Message was edited by:
    USER_X

  • Send html with mail app

    Hi,
    I'm looking for a way send an HTML well designed e-mail through Mail app. Can anyone help?
    Thanks,

    Upper right corner for templates

  • How can i send the chinese sms using java J2EE(web application)

    hi,
    i have the difficulty on sending chinese sms using J2EE application.i try to input the chinese word to jsp and send the plain text sms. i received the sms with plenty of question mark "?????". i think it is regarding to the conversion of String to some kind of format that supported by mobile phone. below are some code the send the sms to recipient. i need someone help in order to have the solution.
    thanks a lot
    <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
    <%@ page import="se.sapio.rta.service.MPMService"%>
    <%@ page import="java.util.Locale"%>
    <%
         Locale.setDefault(Locale.UK);
         Context ctx;
         MPMService mpmservice;
         ctx = new InitialContext();
         mpmservice = (MPMService) ctx.lookup("BC/Service/RTAMPM");
         LSUser user = null;
         boolean ok = true;
         try {
         if (ok) {
              String sender = request.getParameter("sender");
              String phonenr = request.getParameter("phonenr");
              String sendmsg = request.getParameter("sendmsg");
              if(bError) {
                   byte[] bytes = message.getBytes("UTF-8");
                   message = mobileclientservice.ByteEncode(bytes);          
                   response.sendRedirect("send_sms.jsp?s="+request.getParameter("s")+"&msg="+message+"&phonenr="+request.getParameter("phonenr").replaceAll("\\+","%2B")+"&sender="+request.getParameter("sender")+"&sendmsg="+request.getParameter("sendmsg").replaceAll("\\+","%2B"));
              String resp = "";
              if(mpmservice.sendPlainTextSMS(sender, phonenr, sendmsg)) {
                   resp=mpmservice.getLang(user.getLang(), "sms_sent");
              } else {
                   resp=mpmservice.getLang(user.getLang(), "sms_not_sent");
              } %>
              <jsp:include page="/top.jsp" />
              <p class="headline"><%=mpmservice.getLang(user.getLang(), "send_sms_title")%></p>
              <form name="operatordetails" id="operatordetails" method="post" action="send_sms.jsp">
              <INPUT TYPE=hidden NAME=s VALUE="<%=request.getParameter("s")%>">
              <INPUT TYPE=hidden NAME=phonenr VALUE="<%=request.getParameter("phonenr")%>">
              <table class="infotable" id="report">
                   <tr>
                        <td class="left" colspan="2"><%=resp%></td>
                        <td class="right"></td>
                   </tr>
                   <tr>
                        <td class="left" colspan="2">
                             <input class="halfmiddle" name="Back" type="submit" id="Back" value="<%=mpmservice.getLang(user.getLang(), "back")%>" />
                        </td>     
                        <td class="right"> </td>
                   </tr>
              </table>
              </form>
              <jsp:include page="/bottom.jsp" />
         <% } %>
       public boolean sendPlainTextSMS(String sender, String recipient, String sendmsg){
             if(recipient.charAt(0) == '+')
                   recipient = recipient.substring(1);
             String senderIdType = "Alpha";
              if( (sender.charAt(0) >= '0' && sender.charAt(0) <= '9') || sender.charAt(0) == '+')
                   senderIdType = "Numeric";
                   if(sender.charAt(0) == '+')
                        sender = sender.substring(1);
                   for(int i=0; i < sender.length(); i++)
                        if(!(sender.charAt(i) >= '0' && sender.charAt(i) <= '9'))
                             senderIdType = "Alpha";
             log.warn("sending sms to: "+recipient + " sendtype: " + senderIdType + " msg: "+ sendmsg);
             log.warn("Encoded sms:"+Encode(sendmsg));
             try{
             String postData = "XMLDATA=" + URLEncoder.encode("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\r\n" +
                        "<NotificationRequest Version=\"3.4\">\r\n" +
                        "     <NotificationHeader>\r\n" +
                        "          <PartnerName>" + SMS_PARTNER_NAME + "</PartnerName>\r\n" +
                        "          <PartnerPassword>" + SMS_PARTNER_PASSWORD + "</PartnerPassword>\r\n" +
                        "          <SubscriptionName>XML</SubscriptionName>\r\n" +
                        "     </NotificationHeader>\r\n" +
                        "     <NotificationList BatchID=\"1\">\r\n" +
                        "          <Notification SequenceNumber=\"0\" MessageType=\"SMS\">\r\n" +
                        "          <Message>" + Encode(sendmsg) + "</Message>\r\n" +
                        "          <Profile>" + SMS_PARTNER_PROFILE + "</Profile>\r\n" +
                        "          <SenderID Type=\"" + senderIdType + "\">" + sender + "</SenderID>\r\n" +
                        "          <Subscriber>\r\n" +
                        "               <SubscriberNumber>" + recipient + "</SubscriberNumber>\r\n" +
                        "          </Subscriber>\r\n" +
                        "      </Notification>\r\n" +
                        " </NotificationList>\r\n" +
                        "</NotificationRequest>","ISO-8859-1");
      appreciate for anyone provide the solution.
    thanks a lot

    Hi,
    I want to send sms from web application to mobile phones at the time of registration. Its verymuch greatful to me, if you let me know, how to send from jsp to mobile. because from your post, i got, you already know about sending sms from jsp to mobile.
    please let me know, how to send sms
    [email protected]
    Thanks in advance for your kind help

  • How to send results to actionscript using java

    Hi,
    I do RPC using HttpService.
    In my situation, I need to send results from Java code to
    Flex Action script. I have defined a Java Servlet receiving data
    from Flex application, then it processes with the data, finally the
    Servlet is supposed to send some feedbacks to the client(Flex).
    My question is that how can I define codes in doPost() method
    that the following function will get "result" from the Java side.
    public static function httpResult(event:ResultEvent):void
    var result:Object = event.result;
    //Do something with the result.
    if (result.toString() == "success")
    resultMessage.text = "Login Success";
    resultMessage.text = "Invalid User";
    }

    Hi,
    Try this: If you are sending a simple text as "sucess" or
    "error" after doing some process in the servlet..
    set your content type to "text/plain" and simply
    println(<data to be sent>);
    In the flex application, get the result text that the servlet
    send using:
    resultString = String(httpUrl.lastResult);
    where httpUrl is the id of the HTTPService. Now you can
    compare what the servlet send by:
    if(resultString=="sucess") {
    Hope this solves your problem :)
    Regards,
    -- Abdel Olakara
    http://olakara.googlepages.com
    http://technopaper.blogspot.com

  • How to send results to actionscript using java via HttpService

    Hi,
    I do RPC using HttpService.
    In my situation, I need to send results from Java code to
    Flex Action script. I have defined a Java Servlet receiving data
    from Flex application, then it processes with the data, finally the
    Servlet is supposed to send some feedbacks to the client(Flex).
    My question is that how can I define codes in doPost() method
    that the following function will get "result" from the Java side.
    public static function httpResult(event:ResultEvent):void
    var result:Object = event.result;
    //Do something with the result.
    if (result.toString() == "success")
    resultMessage.text = "Login Success";
    resultMessage.text = "Invalid User";
    }

    I advise having your servlet build an xml string, maybe put a
    status attribute in the root tag, like this:
    <myroot status="success">
    <mytext>Some text</mytext>
    </myroot>
    and return that to the calling Flex client. XML is easier to
    work with than Object. On the HTTPService tag, set
    resultFormat="e4x", and it will return plain XML.
    then in the handler, do:
    var xmlResult:XML = XML(event.result); //this will already be
    the myroot node
    //Do something with the result.
    if (xmlResult.@status== "success") //reads the status
    attribute
    resultMessage.text = xmlResult.mytext.text(); //get the
    value of themytext text() node
    resultMessage.text = "Error";
    Tracy

  • How to read and then extract HTMl source code using java program?

    Hi,
    Could someone tell me how to read and then extract the content of certain tag from html source code. For example, given url http://.... , I would like to know what the <Title> content <Title> in that page is.
    Any help is greatly appreciate.

    Use a URLConnection to make the connection to the page at the needed URL. From the URLConnection, you can get an InputStream that is the stream of data from that page. Just search through the stream and find the <title> tags (don't forget to check for case sensitivity).

Maybe you are looking for

  • Assign chart of account to a new company code

    Dear all, I have created a new company code in system(copy an existing company code data). When I am going to a new chart of account to the new company code, system display an error message as follows: Reset company code data before changing the char

  • How to control swf file loaded in flash builder project?

    Condition : 1. I have a swf file presentation. 2. A flex mobile project using flash builder 4.6 with its default SDK. What i want : 1. Include those swf file into my flex mobile project and interact with those swf like i run it on flash player for PC

  • Product key not valid error while installing CRXI

    Post Author: JSC CA Forum: Upgrading and Licensing I purchased CRXI a few months ago, but waited till I had my new hard drive in place before. At the "user information dialog I entered the only product key code I could find in the case, attached to t

  • F1109: Line Item 001

    Dear All, After client copy, When posting MIGO, Transfers system showing 'Express document update error...'. When checked the details of error info showing as : F1 109 : Line item 001. Any suggestions to solve this issue with number ranges. Regards,

  • ITunes not importing mp3

    I have this album which i have imported into itunes many times. But since updating recently, and realising its not there anymore. When it comes to importing it back into itunes, it just doesnt want to import the songs? any ideas? Im going snowboardin