Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8222033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:08:17+00:00 2026-06-07T14:08:17+00:00

I saw this great question and answer on StackOverflow on embedding an image in

  • 0

I saw this great question and answer on StackOverflow on embedding an image in an email. Unfortunately, the answerer didn’t explain how to split the email with a boundary – he said he didn’t know what the boundary was for.

This is what I tried:

    v_body := '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
  <head>  
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-15"> 
  </head> 
  <body bgcolor="#ffffff" text="#000000"> 
    <img src="data:image/jpg;base64,------------090303020209010600070908' || v_image || '------------090303020209010600070908" /> 
  </body> 
</html>'; 

utl_mail.send('myemail.example.com', 
              'myemail.example.com',
              null,
              null, 
              'Image attachment test',
              v_body,
              'multipart/related; boundary="------------090303020209010600070908"',
              null);   

It sends the base64 string as raw characters instead of converting it into an image.

Then, I tried:

    v_body := 'This is a multi-part message in MIME format. 
--------------090303020209010600070908 
Content-Type: text/html; charset=ISO-8859-15 
Content-Transfer-Encoding: 7bit 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
  <head> 

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-15"> 
  </head> 
  <body bgcolor="#ffffff" text="#000000"> 
    <img src="cid:part1.06090408.01060107" alt=""> 
  </body> 
</html> 

--------------090303020209010600070908 
Content-Type: image/png; 
 name="moz-screenshot.png" 
Content-Transfer-Encoding: base64 
Content-ID: <part1.06090408.01060107> 
Content-Disposition: inline; 
 filename="moz-screenshot.png" 

' || v_image || '

--------------090303020209010600070908-- '; 

utl_mail.send('myemail.example.com', 
              'myemail.example.com',
              null,
              null, 
              'Image attachment test',
              v_body,
              'multipart/related; boundary="------------090303020209010600070908"',
              null);   

The email content was not visible this time.

So, how can we split apart an email with a multipart/related MIME type using a boundary in Oracle?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T14:08:20+00:00Added an answer on June 7, 2026 at 2:08 pm

    I have used utl_smtp package:

    procedure send_email (
        p_image blob
        )
      is
        conn utl_smtp.connection;
        BOUNDARY  VARCHAR2 (256) := '-----090303020209010600070908';
        i         pls_integer;
        len       pls_integer;
        buff_size pls_integer := 57;
        l_raw     raw(57);
      begin

    conn := UTL_SMTP.open_connection (smtp_host, smtp_port);
    UTL_SMTP.helo (conn, smtp_domain);
    UTL_SMTP.mail (conn, 'myemail@example.com');
    UTL_SMTP.rcpt (conn, 'myemail@example.com');
    UTL_SMTP.open_data (conn);
    UTL_SMTP.write_data (conn, 'From' || ': ' || 'myemail@example.com'|| UTL_TCP.CRLF);
    UTL_SMTP.write_data (conn, 'To' || ': ' || 'myemail@example.com'|| UTL_TCP.CRLF);
    UTL_SMTP.write_data (conn, 'MIME-Version: 1.0' || CHR (13) || CHR (10));
    UTL_SMTP.write_data (conn, 'Content-Transfer-Encoding: 8bit' || CHR (13) || CHR (10));
    UTL_SMTP.write_data (conn, 'Subject: image in attachment' || CHR (13) || CHR (10) ) ;
    UTL_SMTP.write_data (conn, 'Content-Type: multipart/mixed; boundary="' || BOUNDARY || '"' || UTL_TCP.CRLF);
    UTL_SMTP.write_data (conn, 'X-Mailer:Mailer by Oracle UTL_SMTP');
    UTL_SMTP.write_data (conn, UTL_TCP.CRLF);
    UTL_SMTP.write_data (conn, 'This is a multi-part message in MIME format.' || UTL_TCP.crlf);
    UTL_SMTP.write_data (conn, '--' || BOUNDARY || UTL_TCP.CRLF );
    UTL_SMTP.write_data (conn, 'Content-Type: text/html; charset="windows-1251"'|| UTL_TCP.CRLF );
    UTL_SMTP.write_data (conn, UTL_TCP.CRLF);
    UTL_SMTP.write_data (conn, 'put your html code here');
    UTL_SMTP.write_data (conn, UTL_TCP.CRLF);
    UTL_SMTP.write_data (conn, '--' || BOUNDARY || UTL_TCP.CRLF );
    UTL_SMTP.write_data (conn, 'Content-Type: image/jpeg;'|| UTL_TCP.CRLF );
    UTL_SMTP.write_data (conn, 'Content-Disposition: inline; filename="image.jpg"' || UTL_TCP.CRLF);
    UTL_SMTP.write_data (conn, 'Content-Transfer-Encoding' || ': ' || 'base64' || UTL_TCP.CRLF);
    UTL_SMTP.write_data (conn, 'Content-ID: <part1.06090408.01060107>');
    UTL_SMTP.write_data (conn, UTL_TCP.CRLF);
    UTL_SMTP.write_data (conn, UTL_TCP.CRLF);

    i := 1;
    len := dbms_lob.getlength(p_image);
    while i < len
    loop
    dbms_lob.read(p_image, buff_size, i, l_raw);
    utl_smtp.write_raw_data(conn, utl_encode.base64_encode(l_raw));
    utl_smtp.write_data(conn, utl_tcp.crlf);
    i := i + buff_size;
    end loop;
    utl_smtp.write_data(conn, utl_tcp.crlf);
    UTL_SMTP.write_data (conn, '--' || BOUNDARY || '--' || UTL_TCP.CRLF);

    UTL_SMTP.write_data (conn, UTL_TCP.CRLF);
    UTL_SMTP.close_data (conn);
    UTL_SMTP.quit (conn);

    end;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw this as an example on MDN and didn't understand why this was
I saw this question and it motivated me to look again (without success) at
I saw this in a answer by Marc Gravell, and I just don't see
I saw this similar question here but can't figure out how to use Contains
So I saw this great blog post, Experimenting with Node.js . I decided to
I saw this question and it got me interested as surface caused a big
I saw this C# using statement in a code example: using StringFormat=System.Drawing.StringFormat; What's that
I saw this posting which explained how to get BC3 working as the diff
i saw this In MySQL, joins work for INSERT, UPDATE, and DELETE statements. It's
just saw this comment in a what JS lib do you use poll @Xanti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.