Sample Java  Code to send an HTML mail with embeded image

Hello,
Please can I get a sample Java code on sending an HTML mail with embeded image.
The HTML message and relevant input parameters withhbe supplied from a PL/SQL that will call the class , the class will embed the image and send the mail to the recepient.

tev wrote:
Please can I get a sample Java codeNo. This is a forum, not a code mill.
Recommended reading: How to ask questions the smart way
db

Similar Messages

  • Send HTML mail with an image

    Hi there,
    I'm trying to send html mail with an image. I'm able to see the image but in another section, at the very bottom of my message. Is it possible to display the image in the main part of my message ?
    Here my code :
    MimeMultipart multi = new MimeMultipart();
    BodyPart messageBodyPart = new MimeBodyPart();
    String htmlText = <H1>Test</H1><img src=\"cid:image\">";
    messageBodyPart.setContent(htmlText, "text/html");
    multi.addBodyPart(messageBodyPart);
    MimeBodyPart imagePart = new MimeBodyPart();
    DataSource fds = new FileDataSource("C:\\Resources\\Templates\\logo.jpg");
    imagePart.setFileName( "geologo.jpg" );
    imagePart.setDataHandler(new DataHandler(fds));
    imagePart.setHeader("Content-ID","<image>");     
    multi.addBodyPart(imagePart);
    msg.setContent(multi);
    Transport.send(msg);

    How many different e-mail clients have you tested that with?

  • PDF to html conversion with embedded images in java

    hi all,
    i want to convert any pdf file to its html equivalent. currently i am using PDFBOX java api to do that. it works fine with simple pdf files having no images, but if there are embedded images in pdf file then it do not show these images.
    anyone who has clue of solving this problem. i can convert individual pdf pages to jpg pictures if all embedded images would also be in these pictures.
    help me regarding pointers to other APIs, code snippets etc that can solve my purpose.
    thanks in advance

    Hi..
    really soorry i am not having any solution for u.
    But i am having one problem regarding pdf box, i think u know pdf box, i am reading japanese file using pdf box, its giveing
    caught a class java.io.IOException
    with message: Unknown encoding for 'UniJIS-UCS2-H'
    I have wrriten code like this.....
    PDDocument pdfDocument = null;
    PDFParser parser = new PDFParser( new FileInputStream(file));
    parser.parse();
    pdfDocument = parser.getPDDocument();
    PDFTextStripper stripper = new PDFTextStripper();
    String text = stripper.getText(pdfDocument);
    reader = new StringReader(text);

  • Send HTML Email with Embedded Images and CSS

    Hi All,
    I have a html page. I want to send that html page(not with attachment) with all images and css. i search and try but I cant find a good solution. can any one help... plz..........
    Thank You.....

    If you want to send the html page and have it
    reference the images and css files on your web
    site, that's pretty easy. Just create a message
    with text/html content that is your html page.
    If you want to include all the images and css files
    in your message along with the html page, you'll
    need to create a multipart/related message and
    you'll need to change all the html to reference the
    images and css files using "cid:" references.

  • UTL_SMTP send HTML email with embedded image?

    Hi, I can use UTL_SMTP to send an HTML email ok, but does anyone have an example of how to include an inline embedded image in the email? Thanks!

    If you want to send the html page and have it
    reference the images and css files on your web
    site, that's pretty easy. Just create a message
    with text/html content that is your html page.
    If you want to include all the images and css files
    in your message along with the html page, you'll
    need to create a multipart/related message and
    you'll need to change all the html to reference the
    images and css files using "cid:" references.

  • Pdf file to html conversion with embedded images

    hi all,
    i want to convert any pdf file to its html equivalent. currently i am using PDFBOX java api to do that. it works fine with simple pdf files having no images, but if there are embedded images in pdf file then it do not show these images.
    anyone who has clue of solving this problem. i can convert individual pdf pages to jpg pictures if all embedded images would also be in these pictures.
    help me regarding pointers to other APIs, code snippets etc that can solve my purpose.
    thanks in advance

    Hi..
    really soorry i am not having any solution for u.
    But i am having one problem regarding pdf box, i think u know pdf box, i am reading japanese file using pdf box, its giveing
    caught a class java.io.IOException
    with message: Unknown encoding for 'UniJIS-UCS2-H'
    I have wrriten code like this.....
    PDDocument pdfDocument = null;
    PDFParser parser = new PDFParser( new FileInputStream(file));
    parser.parse();
    pdfDocument = parser.getPDDocument();
    PDFTextStripper stripper = new PDFTextStripper();
    String text = stripper.getText(pdfDocument);
    reader = new StringReader(text);

  • Annoying behavior when opening mail with embedded images

    When I open an email that have embedded images within it, I am finding that Mail is always seizing control of the scrolling and is forcing the mail message to return to the top of the page. This happens while I am scrolling though the message and repeats until the message is fully loaded. Does anyone know if there is a work-around or solution to this problem? I find it very annoying, especially if it's a message I don't really care about.
    Thanks!

    I am having the same problem, and would love to know an answer for this, too.

  • How to send HTML mail with images multipart/related message

    Hi,
    Could any body tell me how to send HTML mail with images in "multipart/related" message,if any body can give the code ,it would be helpful.
    Thanks

    Hi,
    Could any body tell me how to send HTML mail with
    ith images in "multipart/related" message,if any body
    can give the code ,it would be helpful.
    ThanksHi!
    Refer to
    http://developer.java.sun.com/developer/onlineTraining/JavaMail/index.html
    I've found it very helpful.
    Look at the last part for a code showing how to send HTML mail!
    Regards

  • Background html images sending an HTML mail

    Hello:
    I'm sending a mail with html format, and i need the images are embebed in the mail.
    I send its like an Attachment, and reference its whith cid:"..." and it works fine while the image isn�t the background, but I need send an html document with an image in background!!!
    Somebody can help me? Its Urgent!
    Any idea its appreciated. Thanks.

    Yes, there is the code:
    Properties props = System.getProperties();
    //props.put("mail.smtp.host","servidor2000.galia.e-netfinger.com");
    props.put("mail.smtp.host",varParametros.varCorreoSaliente);
    Session session = Session.getDefaultInstance(props);
    Message message = new MimeMessage(session);
    InternetAddress from = new InternetAddress(varParametros.varFrom);
    InternetAddress to[] = InternetAddress.parse(varParametros.varTo);
    message.setFrom(from);
    message.setRecipients(Message.RecipientType.TO,to);
    message.setSubject(varParametros.varSubject);
    Multipart multipart1=new MimeMultipart("alternative");
    BodyPart htmlpart=new MimeBodyPart();
    htmlpart.setContent(varCorreo,varContentType); //varContentType=text/html
    MimeMultipart multipart = new MimeMultipart("related");
    multipart.addBodyPart(htmlpart);
    for (int i=0;i<varCCorreo.varFicheroAdjunto.size();i++){
    BodyPart messageBodyPart = new MimeBodyPart();
         CFicheroAdjunto varCFAdjunto=((CFicheroAdjunto)(varCCorreo.varFicheroAdjunto.elementAt(i)));
         DataSource source=null;
         if (varCFAdjunto.varNombre.toLowerCase().endsWith("jpg") ){
         source=new ByteArrayDataSource(varCFAdjunto.varFile,"image/jpeg");
         }else if (varCFAdjunto.varNombre.toLowerCase().endsWith("gif")){
         source=new ByteArrayDataSource(varCFAdjunto.varFile,"image/gif");
         }else{
         source=new ByteArrayDataSource(varCFAdjunto.varFile,"application/xxx" );
         messageBodyPart.setDisposition(Part.ATTACHMENT);
    messageBodyPart.setDataHandler(new DataHandler(source));
    messageBodyPart.setFileName(((CFicheroAdjunto)(varCCorreo.varFicheroAdjunto.elementAt(i))).varNombre);
    messageBodyPart.setHeader("Content-ID","<"+varCFAdjunto.varNombre+">");
    multipart.addBodyPart(messageBodyPart);
    }//end for
    // Put parts in message
    MimeBodyPart mbp = new MimeBodyPart();
    mbp.setContent(multipart);
    multipart1.addBodyPart(mbp);
    message.setContent(multipart1);
    Transport.send(message);
    And in my html code I get:
    <body background="cid:name.jpg">
    Please, I need help!!

  • Send HTML mail with flash

    Hi
    Does anybody knows how to send a HTML mail with flash to a
    person?
    grtz
    Tom

    Hi!
    You need to use a serverside script like php or asp. I have a
    html string in
    the swf which I send as LoadVars.send() to the server.
    Of cource the server has to be configured correctly to
    support the mail
    function.
    //Micke
    "MatMaar" <[email protected]> skrev i
    meddelandet
    news:e3atb2$c2r$[email protected]..
    > Hi
    >
    > Does anybody knows how to send a HTML mail with flash to
    a person?
    >
    > grtz
    > Tom

  • Sample Java code and detail to call RFC from Java clas developed in Eclipse

    Hi All,
    I am new to Java. I have downloaded Eclipse IDE  and planning to use for developing Java application to send data to SAP by calling RFC JCO Interface.
    I need a sample java code/tutorial step by step to create Java class for simple example to call RFC from Java.
    I have downloaded SAPJCO3 from service market place.
    Kindly help me to send steps involved to configure for JCO  with my Eclipse with JCO.
    Thanks in advance.
    Sharma

    Hi Sharma,
    Please have a look at [Example: Using Generated Proxies to Call Function Modules |http://help.sap.com/saphelp_nw04/helpdata/en/b6/55e3952a902447847066a0df27b0d6/content.htm]
    JCo Exceptions : http://help.sap.com/saphelp_nw70ehp1/helpdata/en/f6/daea401675752ae10000000a155106/content.htm
    Hope it will helps
    Regards
    Arun

  • Any sample ABAP code to send Lotus Notes email to a list of people?

    Any sample ABAP code to send Lotus Notes email to a list of people?
    We will give you reward points!

    hi..
      This sample code help you to send mail from SAP .
    REPORT  ZSSO_DOCUMENT_SEND_API1.
    DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS  2 WITH HEADER LINE.
    DATA: OBJHEAD LIKE SOLISTI1   OCCURS  1 WITH HEADER LINE.
    DATA: OBJBIN  LIKE SOLISTI1   OCCURS 10 WITH HEADER LINE.
    DATA: OBJTXT  LIKE SOLISTI1   OCCURS 10 WITH HEADER LINE.
    DATA: RECLIST LIKE SOMLRECI1  OCCURS  5 WITH HEADER LINE.
    DATA: DOC_CHNG LIKE SODOCCHGI1.
    DATA: TAB_LINES LIKE SY-TABIX.
    Creating the document to be sent
    DOC_CHNG-OBJ_NAME = 'OFFER'.
    DOC_CHNG-OBJ_DESCR = 'Auction of a Picasso jr'.
    OBJTXT = 'Reserve price : $250000'.
    APPEND OBJTXT.
    OBJTXT = 'A reproduction of the painting to be auctioned'.
    APPEND OBJTXT.
    OBJTXT = 'is enclosed as an attachment.'.
    APPEND OBJTXT.
    DESCRIBE TABLE OBJTXT LINES TAB_LINES.
    READ TABLE OBJTXT INDEX TAB_LINES.
    DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
    Creating the entry for the compressed document
    CLEAR OBJPACK-TRANSF_BIN.
    OBJPACK-HEAD_START = 1.
    OBJPACK-HEAD_NUM   = 0.
    OBJPACK-BODY_START = 1.
    OBJPACK-BODY_NUM   = TAB_LINES.
    OBJPACK-DOC_TYPE   = 'RAW'.
    APPEND OBJPACK.
    Creating the document attachment
    (Assume the data in OBJBIN are given in BMP format)
    OBJBIN = ' \O/ '. APPEND OBJBIN.
    OBJBIN = '  |  '. APPEND OBJBIN.
    OBJBIN = ' / \ '. APPEND OBJBIN.
    DESCRIBE TABLE OBJBIN LINES TAB_LINES.
    OBJHEAD = 'picasso.bmp'. APPEND OBJHEAD.
    Creating the entry for the compressed attachment
    OBJPACK-TRANSF_BIN = 'X'.
    OBJPACK-HEAD_START = 1.
    OBJPACK-HEAD_NUM   = 1.
    OBJPACK-BODY_START = 1.
    OBJPACK-BODY_NUM   = TAB_LINES.
    OBJPACK-DOC_TYPE   = 'BMP'.
    OBJPACK-OBJ_NAME   = 'ATTACHMENT'.
    OBJPACK-OBJ_DESCR = 'Reproduction object 138'.
    OBJPACK-DOC_SIZE   = TAB_LINES * 255.
    APPEND OBJPACK..
    Entering names in the distribution list
    RECLIST-RECEIVER = '[email protected]'.
    RECLIST-REC_TYPE = 'U'.
    APPEND RECLIST.
    RECLIST-RECEIVER = 'DLI-NEUREICH'.
    RECLIST-REC_TYPE = 'P'.
    APPEND RECLIST.
    Sending the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
         EXPORTING
              DOCUMENT_DATA = DOC_CHNG
              PUT_IN_OUTBOX = 'X'
              COMMIT_WORK   = 'X'
         TABLES
              PACKING_LIST  = OBJPACK
              OBJECT_HEADER = OBJHEAD
              CONTENTS_BIN  = OBJBIN
              CONTENTS_TXT  = OBJTXT
              RECEIVERS     = RECLIST
         EXCEPTIONS
              TOO_MANY_RECEIVERS = 1
              DOCUMENT_NOT_SENT  = 2
              OPERATION_NO_AUTHORIZATION = 4
              OTHERS = 99.
    CASE SY-SUBRC.
      WHEN 0.
        WRITE: / 'Result of the send process:'.
        LOOP AT RECLIST.
          WRITE: / RECLIST-RECEIVER(48), ':'.
          IF RECLIST-RETRN_CODE = 0.
            WRITE 'sent successfully'.
          ELSE.
            WRITE 'not sent'.
          ENDIF.
        ENDLOOP.
      WHEN 1.
        WRITE: / 'no authorization to send to the specified number of'              'recipients!'.
      WHEN 2.
        WRITE: / 'document could not be sent to any of the recipients!'.
      WHEN 4.
        WRITE: / 'no authorization to send !'.
      WHEN OTHERS.
        WRITE: / 'error occurred during sending !'.
    ENDCASE.
    Go for SCOT  transaction to send those mails.
    REGARDS,
    VEERESH

  • How can I set the language when sending an e-mail with attachment - 'Html'?

    "Character Broken"
    I made an ALV program, and this convert to "HTML',  and send an e-mail with this.
    Used Process is:
    DATA: gt_abaplist LIKE TABLE OF abaplist,
          gt_html LIKE TABLE OF w3html,
          doc_chng LIKE sodocchgi1,
          objpack LIKE TABLE OF sopcklsti1 WITH HEADER LINE,
          objhead LIKE TABLE OF solisti1 WITH HEADER LINE,
          mail LIKE TABLE OF solisti1 WITH HEADER LINE,
          reclist LIKE TABLE OF somlreci1 WITH HEADER LINE,
          lv_line TYPE i.
    DELETE FROM MEMORY ID '%_LIST'.
    SUBMIT z_template
       AND RETURN EXPORTING LIST TO MEMORY.
    CALL FUNCTION 'LIST_FROM_MEMORY'
      TABLES
        listobject = gt_abaplist
      EXCEPTIONS
        not_found  = 1
        OTHERS     = 2.
    CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
      TABLES
        html       = gt_html
        listobject = gt_abaplist.
    doc_chng-obj_name   = 'URGENT'.
    doc_chng-sensitivty = 'O'.
    doc_chng-obj_descr  = ' '.
    doc_chng-obj_langu  = '3'.
    objhead-line        = ' '.
    APPEND objhead.
    mail[] = gt_html[].
    DESCRIBE TABLE mail LINES lv_line.
    CLEAR: objpack.
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num   = 0.
    objpack-body_start = 1.
    objpack-body_num   = lv_line.
    objpack-doc_type   = 'htm'.
    objpack-obj_descr  = ' '. 
    objpack-doc_size   = lv_line * 255.
    objpack-obj_langu = '3'.
    APPEND objpack.
    CLEAR: reclist.
    reclist-receiver = 'e-mail address'.
    reclist-rec_type = 'U'.
    APPEND reclist.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        document_data              = doc_chng 
        put_in_outbox              = 'X'
        commit_work                = 'X'
      TABLES
        packing_list               = objpack
        object_header              = objhead
        contents_bin               = mail
        receivers                  = reclist
      EXCEPTIONS
        too_many_receivers         = 1
        document_not_sent          = 2
        document_type_not_exist    = 3
        operation_no_authorization = 4
        parameter_error            = 5
        x_error                    = 6
        enqueue_error              = 7
        OTHERS                     = 8.
    SUBMIT rsconn01 AND RETURN.
    I want to show  this by "Japanese".
    But the character is broken.
    LIke This:
    u01D1u072C          u0205|            u0205u072C          u0508           QC u04B90m
    How can I set the language?  How can I solve "Charancter Broken" ?
    Plesse, let me know.
    Thank you so much.
    Edited by: Jaime White 999 on Nov 21, 2011 8:45 AM
    Edited by: Jaime White 999 on Nov 21, 2011 8:46 AM

    Hi Jaime,
    Are you saying, you are getting junk characters in the email attachment? Then pls check the following. Since you want to send Japanese fonts, please pass language 'J' in both  objpack-obj_langu = '3' & doc_chng-obj_langu  = '3' instead of '3' please replace it with 'J'.
    Another thing which you may have to check is the SCOT device type. As I understand from my basis colleague, this may also affect your attachment fonts since the emails are sent through SCOT. Go to transaction SCOT-> Settings-> Device types for format conversion. Check whether wrong device type is defined for Japanese there. Hope this helps
    Regards,
    Gokul

  • Send html mail with apple mail

    I used to send a html newsletter with apple mail. I opened the html file in safari pressed cmd + i and a html mail was created. On Yosemite there seems to be a bug with this feature. After pressing cmd + i it creates a mail and html website is selected in this mail, but the mail body is empty. Now I have no ideo how to send the newsletter. Apple mail was the only way to achive a correctly displayed newsletter on most common mail clients.
    Does anyone have the same problem or a solution?

    Seems to be a bug in Safari under Yosemite. Occurs only with HTML pages which are stored locally on the Mac and then opened with Safari.
    Two options for a work around:
    (1)
    When Apple Mail shows a blank page, choose PDF instead of WEB PAGE in the mail header.
    Thereafter, the contents will appear as a PDF attachment.
    (2)
    Publish the HTML page. Surf with Safari to the published page. Use the command "File : Send : Email this page".
    Now it should work.

  • Need Sample java code

    Hi,
    iam working in SAP .
    I need sample java code on how to convert Decimal to number
    For Ex: I/p-----123.11
    O/p----------------12311 ( with out decimal) want to remove the dicimal point what ever the input value and deliver it to the output
    Please give me code
    Regards
    Suman

    i don't know what do you want to do really. If you are doing it simply then you can take the input in a String and then remove the decimal.
    String str = "123.11";
    str = str.substring(0, str.indexOf("."));
    System.out.println(str);

Maybe you are looking for

  • Firefox 3.6.10 will not open Snapfish which runs with Firefox 3.6.9 so how do I get it to work.

    Every time I open Firefox, it insists on upgrading itself to 3.6.10. Yesterday, I gave in and let it upgrade. To get my photo storage site to work, I had to "restore" my system before the download. Now it is still there wanting to upgrade itself, and

  • Dreaded "Operations Manager failed to start a process" error (2012 R2)

    I know this error has been covered many times, and on many topics, but this time mine is slightly different.   It's NOT the "SCOMpercentageCPUTimeCounter" error covered by Kevin Holman. Also, I am running SCOM 2012 R2 UR4 (7.1.10226.1046) and everyth

  • How can I purge and delete OFFILES FOLDER

    Hi , I have groupwise 7.0 version. and I have 1 volume with 100 GB used... and the OFFILES Folder takes most of the space, how can I reduce this folder and not affect the mail system.. I will waiting for your comments.. Regards.. Roberto Tamez

  • Sun Directory Server and OID Synchronization

    I'm having a problem with synchronizing OID with our existing Sun Directory Server. This is a one way synchronization, using Sun DS as the source, and OID as the destination. I've successfully installed OID with SSL enabled (this is part of an Oracle

  • Photoshop CC images

    Hi all, After being away i have return to eagerly install Photoshop CC. However to disappointment. After installing all seemed fine. Then I opened my 1st image... ...the image looked terrible on the screen, as if it had been posterize. I tried anothe