Superdooperhero
Superdooperhero

Reputation: 8096

Oracle utl_smtp not working as expected with multipart/alternative content type

I would like to use the following example by Ask Tom, but it does not work as expected. When I call it with

declare
begin
xxpay_smtp.html_email
(
   p_to            => '[email protected]',      -- in varchar2,
   p_from          => '[email protected]',   -- in varchar2,
   p_subject       => 'Subject FD',                    -- in varchar2,
   p_text          => 'Body FD',                       -- in varchar2 default null,
   p_html          => '<html>
    <head>
        <title>some subject</title>
    </head>
    <body>
        Your <b>Html</b> email message here.
    </body>
</html>',                     -- in varchar2 default null,
   p_smtp_hostname => 'smtp.com',       -- in varchar2,
   p_smtp_portnum  => '25'                             -- in varchar2
);       
end;

It comes back with an email body that looks like this:

Body FD

--a1b2c3d4e3f2g1
content-type: text/html;

<html>
    <head>
        <title>some subject</title>
    </head>
    <body>
        Your <b>Html</b> email message here.
    </body>
</html>
--a1b2c3d4e3f2g1--

I am using Outlook 2010. Does anyone know where the Ask Tom example goes wrong, or what I am doing wrong?

Thanks

Upvotes: 0

Views: 1412

Answers (1)

Jeffrey Kemp
Jeffrey Kemp

Reputation: 60262

There needs to be an extra blank line after the headers, i.e. after the "Content-Type" line.

l_temp := l_temp || 'Content-Type: multipart/alternative; boundary=' || 
                     chr(34) || l_boundary ||  chr(34) || chr(13) || 
                     chr(10);

Needs to be changed to:

l_temp := l_temp || 'Content-Type: multipart/alternative; boundary=' || 
                     chr(34) || l_boundary ||  chr(34) || chr(13) || 
                     chr(10) || chr(13) || chr(10);

Upvotes: 2

Related Questions