How to put an image to any part of an e-mail using UTL_SMTP

We need to send an e-mail with the following format.
|COMPANY LOGO (JPEC IMAGE)          |
|                                    |
|                                    |
|              HTML table            |
|                                    |
|                                    |
------------------------------------The exact format is shown here: http://postimage.org/image/76v4e5tmd/
Above the Automatic Payment Advice is the JPEG image.
How do we CONSTRUCT THIS e-mail? Our DB is a 10g R2. We use UTL_SMTP. Problem is how to insert an image to any part of the e-mail (not as a separate attachment)?
Edited by: Channa on May 24, 2012 5:51 AM

Yes. It is possible. Read this posts of Billy Verreynne to uderstand the MIME format.
Re: Sending HTML mail with inline/embeded images (My code is constructed on this input)
embeded image in email body in pl/sql
DECLARE
  /*LOB operation related varriables */
  v_src_loc  BFILE := BFILENAME('TEMP', 'otn.jpg');
  l_buffer   RAW(54);
  l_amount   BINARY_INTEGER := 54;
  l_pos      INTEGER := 1;
  l_blob     BLOB := EMPTY_BLOB;
  l_blob_len INTEGER;
  v_amount   INTEGER;
  /*UTL_SMTP related varriavles. */
  v_connection_handle  UTL_SMTP.CONNECTION;
  v_from_email_address VARCHAR2(30) := '[email protected]';
  v_to_email_address   VARCHAR2(30) := '[email protected]';
  v_smtp_host          VARCHAR2(30) := 'x.xxx.xxx.xxx'; --My mail server, replace it with yours.
  v_subject            VARCHAR2(30) := 'Your Test Mail';
  l_message            VARCHAR2(32767) := '<html>
<meta http-equiv=3DContent-Type content=3D"text/html; charset=3Dus-ascii">
<body background=3D"cid:[email protected]">
..rest of mail
</body>
</html>
  /* This send_header procedure is written in the documentation */
  PROCEDURE send_header(pi_name IN VARCHAR2, pi_header IN VARCHAR2) AS
  BEGIN
    UTL_SMTP.WRITE_DATA(v_connection_handle,
                        pi_name || ': ' || pi_header || UTL_TCP.CRLF);
  END;
BEGIN
  /*Preparing the LOB from file for attachment. */
  DBMS_LOB.OPEN(v_src_loc, DBMS_LOB.LOB_READONLY); --Read the file
  DBMS_LOB.CREATETEMPORARY(l_blob, TRUE); --Create temporary LOB to store the file.
  v_amount := DBMS_LOB.GETLENGTH(v_src_loc); --Amount to store.
  DBMS_LOB.LOADFROMFILE(l_blob, v_src_loc, v_amount); -- Loading from file into temporary LOB
  l_blob_len := DBMS_LOB.getlength(l_blob);
  /*UTL_SMTP related coding. */
  v_connection_handle := UTL_SMTP.OPEN_CONNECTION(host => v_smtp_host);
  UTL_SMTP.HELO(v_connection_handle, v_smtp_host);
  UTL_SMTP.MAIL(v_connection_handle, v_from_email_address);
  UTL_SMTP.RCPT(v_connection_handle, v_to_email_address);
  UTL_SMTP.OPEN_DATA(v_connection_handle);
  send_header('From', '"Sender" <' || v_from_email_address || '>');
  send_header('To', '"Recipient" <' || v_to_email_address || '>');
  send_header('Subject', v_subject);
  --MIME header.
  UTL_SMTP.WRITE_DATA(v_connection_handle,
                      'MIME-Version: 1.0' || UTL_TCP.CRLF);
  UTL_SMTP.WRITE_DATA(v_connection_handle,
                      'Content-Type: multipart/related; ' || UTL_TCP.CRLF);
  UTL_SMTP.WRITE_DATA(v_connection_handle,
                      ' boundary= "' || 'SAUBHIK.SECBOUND' || '"' ||
                      UTL_TCP.CRLF);
  UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
  -- Mail Body
  UTL_SMTP.WRITE_DATA(v_connection_handle,
                      '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
  UTL_SMTP.WRITE_DATA(v_connection_handle,
                      'Content-Type: text/html;' || UTL_TCP.CRLF);
  UTL_SMTP.WRITE_DATA(v_connection_handle,
                      ' charset=US-ASCII' || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(v_connection_handle,
                      'Content-Transfer-Encoding: quoted-printable' || UTL_TCP.CRLF);                     
  UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
  UTL_SMTP.WRITE_DATA(v_connection_handle, l_message || UTL_TCP.CRLF);
  UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
  -- Mail Attachment
  UTL_SMTP.WRITE_DATA(v_connection_handle,
                      '--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
  UTL_SMTP.WRITE_DATA(v_connection_handle,
                      'Content-Disposition: inline; filename="otn.jpg"' || UTL_TCP.CRLF);
  UTL_SMTP.WRITE_DATA(v_connection_handle,
                      'Content-Type: image/jpg; name="otn.jpg"' ||
                      UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(v_connection_handle,
                      'Content-ID: <[email protected]>; ' ||
                      UTL_TCP.CRLF);                     
  UTL_SMTP.WRITE_DATA(v_connection_handle,
                      'Content-Transfer-Encoding: base64' || UTL_TCP.CRLF);
  UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
  UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
  /* Writing the BLOL in chunks */
  WHILE l_pos < l_blob_len LOOP
    DBMS_LOB.READ(l_blob, l_amount, l_pos, l_buffer);
    UTL_SMTP.write_raw_data(v_connection_handle,
                            UTL_ENCODE.BASE64_ENCODE(l_buffer));
    UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
    l_buffer := NULL;
    l_pos    := l_pos + l_amount;
  END LOOP;
  UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
  -- Close Email
  UTL_SMTP.WRITE_DATA(v_connection_handle,
                      '--' || 'SAUBHIK.SECBOUND' || '--' || UTL_TCP.CRLF);
  UTL_SMTP.WRITE_DATA(v_connection_handle,
                      UTL_TCP.CRLF || '.' || UTL_TCP.CRLF);
  UTL_SMTP.CLOSE_DATA(v_connection_handle);
  UTL_SMTP.QUIT(v_connection_handle);
  DBMS_LOB.FREETEMPORARY(l_blob);
  DBMS_LOB.FILECLOSE(v_src_loc);
EXCEPTION
  WHEN OTHERS THEN
    UTL_SMTP.QUIT(v_connection_handle);
    DBMS_LOB.FREETEMPORARY(l_blob);
    DBMS_LOB.FILECLOSE(v_src_loc);
    RAISE;
END;Otn logo is in my database server and It will embade otn logo all over the mail body!.
Edited by: Saubhik on May 24, 2012 9:06 PM
Changed the original IP and email address. I should have done this earlier!: Saubhik on May 25, 2012 11:20 AM

Similar Messages

  • Any one know how to put an image in a textarea?

    Any one know how to put an image in a textarea?

    yes, it is post on the forum, did you search?

  • How I put photos / images at facebook page? The files do not open.

    How I put photos / images at facebook page? The files do not open.

    The crash happens on setting up the audio hardware. Either you have a broken driver or your preferences is damaged. You can try deleting the MainStage preferences.

  • I don't know how to put an image instead of colours for background

    I am usin awt and I want to put an image from my HD as background instead typical colours. How can I do this?

    Ah. This one is mine. You can try making a Frame anonymus class and overriding paint(). Do you know how to get your picture?
    {=^)                                                                                                                                                                                                                                                                           

  • How to put an image infront of a link as in the Oracle E-Business Suite

    I have noticed that when the main page opens in the EBS after login, the links that we see has a small square icon infront of it.
    Can anyone let me know whats the name of this image and how to put it infront of the links on my main page.
    Regards

    Hi Gaurav,
    I have just found out that in the E-business suite, when you click a link with the icon as fwkhp_formsfunc.gif then it opens up Oracle Forms based interfaces, whereas when you click on a link with fwkhp_sswafunc.gif as an icon, then OAF based pages opens up.
    Just thought of sharing with you.
    Regards

  • Urgent : how to put an image into database and how to get it from it?

    hi,
    in the database i made a longblob type for image, and in my java code i have the path of the image (String): "C:\............." and i want to put this image in my data base.
    also i want to know how to get the image after put it in the database.
    please help me, it's so urgent.

    This is a way of getting the image out of the database.
    class yourClass{
    private byte[] buff;
    private ByteArrayOutputStream byteArrayOutputStream;
    public yourClass()
    Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    ResultSet result = statement.executeQuery("your query");
    while ( result.next()){
    try{
    BufferedInputStream bin = new BufferedInputStream(rs.getBinaryStream("imagecolumn"));
    byteArrayOutputStream = new ByteArrayOutputStream();
    int length = bin.available();
    buff = new byte[length];
    while ( bin.read( buff, 0, length ) != -1 ) {
    byteArrayOutputStream.write( buff, 0, length );
    bin.close();
    catch(Exception e){
    The class about is used to take the image out of the database and store it in an object which is then streamed out through a servlet to display on the jsp page.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    public class ImageServlet extends HttpServlet {
    public void init() throws ServletException {    }
    public void destroy() {    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    try
    yourClass pro = (yourClass)request.getSession().getAttribute("object");
    while ( iterator.hasNext() ) {
    pro = ( Product ) iterator.next();
    response.setContentType("image/jpg");
    ByteArrayOutputStream byteArrayOutputStream = pro.getImage();
    response.setContentLength( byteArrayOutputStream.size() );
    response.getOutputStream().write( byteArrayOutputStream.toByteArray() );
    response.getOutputStream().flush();
    return;
    catch (Exception e)
    e.printStackTrace();
    throw new ServletException(e);
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    doGet(request, response);
    This is a little messy but if you search the forums you will find out more on it. Search for Images and database.

  • How to put an image in a data grid in Flex Builder 2

    Hi All,
    I need to populate a data grid with some text data received
    from a web service and, in a particular column of the datagrid, I
    have to put an image depending of a specific data returned me by
    the web service.
    It seems that there is the possibility to add an image in
    data grid column with the cellRenderer properties, but this
    property is available only for ActionScript 3.
    I'm developing an application in Flex Builder 2 that run
    ActionScript 2 and cellRenderer properties is not available. Is it
    right?
    If no, I will can use this cellRenderer properties in my
    application. Please, can you show me an example?
    If yes, there is a way to insert an image in datagridcolumn
    with ActionScript 2?
    Thank you very much
    Regards

    Flex Builder 2 uses Actionscript 3.
    You will need to write a renderer for for this column.
    There are a lot of examples of datagrids with images in them.
    here is one from the livedocs
    http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Live Docs_Book_Parts&file=cellrenderer_072_28.html

  • How to put an image in the popup help of a page item?

    I am using APEX 2.2. I want to put an image in the help text of a page input item.
    This is the help text:
    Some help text....
    <p><img src="&APP_IMAGES.auto_lov.jpg" /></p>This is rendered as:
    <p><img src="wwv_flow_file_mgr.get_file?p_security_group_id=0&p_flow_id=103&p_fname=auto_lov.jpg" /></p>As you can see, the application id is not returned.
    If I put exactly the same text in a html region, the image is correctly displayed:
    <p><img src="wwv_flow_file_mgr.get_file?p_security_group_id=844129086577364&p_flow_id=103&p_fname=auto_lov.jpg" />So, is it possible at all to put in image in the popup help text of a page item?

    I solved it by putting the jpg file in an images directory on the web server instead of in the database. Not really what I want, but it works.
    <p><img src="&IMAGE_PREFIX./apps/auto_lov.jpg" /></p>

  • How to put an image in Webdynpro

    HI,
    I want to piut a logo in Webdynpro view.I have put the image(logo) in proper place.But I am not able to fetch the data from that folder in to my WD view.
    pLease suggest
    Regards
    -Sandip

    Hi Sandip,
    You want to embed a TextView UI element and an Image UI element in a Group UI element, kindly have a look :-
    http://help.sap.com/saphelp_nw70/helpdata/EN/5d/1d353ed106ec2ce10000000a114084/frameset.htm
    URL Generation Service :-
    http://help.sap.com/saphelp_nw70/helpdata/EN/9e/a073001903c9419592b14c2aa63669/frameset.htm
    Hope this is useful.
    Regards,
    Anagha

  • How to put an Image as a background of Portal

    Hi All,
    I was exploring of possibility of how to include an image as background of portal. I want to see in backdrop ,instead of default portal them ,an image as background.
    Thanks
    Srikant

    Hi Srikant,
    This url will help you in creating a new portal theme and assigning them to your application.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/help/sdn_nw04/saphelp_nw04/helpdata/en/1a/d7c1617dd29e4d85064b467636fada/content.htm
    Best Regards,
    Nibu.
    (Please close your queries if you get your problem solved).

  • Need advice on how to export ALL images including any changes (Versions)

    I have well over 15000 RAW ORF Olympus images in Aperture with approximately 10000 of them in the database and the rest as references to the file on the file system.
    My problem is 'many' fold...
    First I am frustrated with using Aperture only because it doesn't seem to perform well anymore either because I have too many files, the database is corrupted, DB IO is slow... I don't know but its not performing as it did when I started using it and I don't know what to do to fix it... so with that said here are a few options I am pursuing and the problems I am having doing so.
    I am moving to Adobe Bridge and Photoshop CS4, however with most of the files in the Aperture database I need to have them exported... however the only options are Master and or Version, which is frustrating because if I choose Master I get the original RAW file less all the changes done to any versions and if I choose the version I get customized JPEG's less the RAW master file. huh! I would like if possible some other options but I can understand if they don't exist.
    1. One option would be to get all the masters (which I can do now) but only if they are in the database and not referenced.
    2. Second option only would be to get all the versions if the RAW was modified and not export a version for a selected image if it does not exist.
    3. Third, have some way to only selected actual modified version images and not every image in a folder or in the database.
    4. Export to Photoshop .psd format with layers instead of versions?
    5. Filter by files in the database and files that are referenced.
    6. ... I'm open to other suggestions.
    Is there a way to move all the database files back to file referenced to shrink the Database or do I need to export everything and then re-import them as references?
    The export process for so many files is killing me as its taking me days and days and I have no way to cross check to ensure all the files and versions are retained when exported - I'm not sure what I have or how to rebuild them in Aperture at a later time once exported?
    I am exporting the sidecar file with every image but am not sure the value or significances of this file - can this file help when moving to Photoshop/Bridge?
    BTW. Another reason I wish to move from having Aperture manage my files in its database is I have now lost a few hundred unrecoverable pictures for no known reason in aperture, once after a trap as I was processing a image, I lost all of my sisters funeral shots - so so sad.
    Help!!!

    Something is very very very wrong - 15,000 images are nothing, unless you have them all in one project. I have 300,000+ with no issues in performance. Another indicator is days to export 15,000. Don't blame Aperture - you have a giant problem.
    I am not going to address how to do what you want exactly because I do not have the time but here are some hints -
    You can search for adjusted versions, and you can search for managed vs. referenced (file status). You may want to think about using relocate master with some clever subfolder options/selections to put all of you original masters and any external edited masters (PSD, etc) into a nice neat hierarchy for you to browse via bridge - Aperture is fantastic at reorganizing directory structures via relocate masters.
    There is no way to export adustments+RAW that Photoshop can interpret. If you want the Aperture non-destructive adjustments you must export versions end of story.
    Personally I would figure out why you are having such issues with Performance - there is a cause and it will probably give you issues no matter what you are using down the road.
    RB

  • How to put fixed image in a movie

    Just want to put a fixed logo at the left bottom on a full movie. Any idea how to do that ?

    Create a JLabel to display the image - eg as described in the (currently)
    adjacent post http://forum.java.sun.com/thread.jspa?threadID=5128582
    Add the JLabel to a JInternalFrame
    http://java.sun.com/javase/6/docs/api/javax/swing/JInternalFrame.html
    Add the JInternalFrame to your JDesktopPane
    http://java.sun.com/javase/6/docs/api/javax/swing/JDesktopPane.html
    Internal frames are described in Sun's tutorial here:
    http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html
    You should ask Swing questions in the [url http://forum.java.sun.com/forum.jspa?forumID=57]Swing forum.

  • How to put background image on whole screen of javaFx app

    Hello,
    I have a javaFx window,on which u have displayed certain data that is coming from a webservice call.
    Now to make it look attractive,i want to put a background image on the screen.
    I know the image tag in the content,but it does not cover the whole screen and is not below the data.
    How can i do that??
    Also, how can i change color of the text. In the Text attribute,we have font,but nothng to change its color...
    Please help
    Thanks
    Anuj

    Hi,
    I don't know about the background image but the color of Text can be set using the fill property of a Text node.
    Text {
      content: "Hello World"
      font: Font {
        size: 100
      x: 100
      y: 100
      fill: Color.RED
      stroke: Color.BLACK
      strokeWidth: 3
    - Alexander

  • How to put jpeg image under text

    Hello, newbie here to FCE. I am editing a show and want to add my church's color logo under the lower third text I already have in the timeline. I can't figure out how to do it. If it is at all possible could someone please help. It would make my edited show look very professional. Any help or ideas would be appreciated.
    G4,   Mac OS X (10.4.3)  

    Hi Willard.
    You did not mention footage on V1 in your original question.
    I thought you just wanted the jpeg with the text superimposed. For that you would simply put the jpeg on V1 and the text on V2 and it should play immediately.
    However, now you mention some other footage which brings in a whole new dimension.
    Originally I assumed the jpeg was intended to cover the whole frame but now it sounds as though it is just a small emblem.
    Try to describe exactly what you are doing and what it should look like.
    In the meantime just play with the logo and title on the tracks I mentioned and you will see how it works (without the other footage for the time being).
    Ian.

  • I bought wooden keys for my macbook pro. Will putting them on void any part of my warranty

    I have the basic warranty that comes with the macbook, but its double to two years since i used american express card. Will putting the wooden keys affect my warranty if something goes wrong. I understand the wooden keys wont be covered. But i dont want to lose any hardware protection because the keys are different. The process of switching never requires me to open the macbook.

    if your wooden keys are the stick on type - then you won't void the warranty.
    if however, you're actually taking the keys off to replace them with wooden ones - then exactly what steve359 says - warranty is out the window.
    would've love to see what it would look like though - interesting aluminum and wood combo

Maybe you are looking for

  • Indesign CS5 shortcuts won't work

    i have just installed creative suite 5 and when i came to open indesign none of the keyboard shortcuts or toolbars were there. i previously used a free trial of indesign cs4 before uninstalling it to install cs5. i have been to edit> keyboard shortcu

  • Gallery caption custom settings - adding blank spaces?

    When using  the custom settings in the Caption option within the Gallery Module I would like to add blank spaces between options but can't find a way to do it. I prefer not to use dashs or other characters for separators. Ie: <filename> blank space/s

  • My speakers on my G71 have a very low output

    I bought my G71 laptop and the speakers have never have any kind of valume the only way i can realy listen to any thing is to plug in mty ear phones i heard this was a problem frome the manufacture. what do i got to do to get this fixed. oh PS. no ad

  • Help with Report Script please :(

    Hi, I'm trying to write a report script with a slight calculation and would really appreciate some help. Ideally I want to create a report where I only get the Account and Value. I select all my members but I need a calculation on the Entity dimensio

  • Carry out repairs...

    hi experts, i have receive following message when i want to modify a Z program: Carry out repairs in non-original system only if they are u rgent. And if i click continue the source code is not editable. What should i do? Thank you.