How does the code look to aatch 2 pdf files to an email with SMTP you attch to PDF

Posted on 2008-10-17
Last Modified: 2013-11-30
I got it working with one PDF attached from oracle using SMTP, but do not no how to get the second attachment onto the same email working.  
I tried duplicating the code, repeating it from the begin_attachment to the end_attachment call only changing filenm parameter value but no luck.

It appears that the on the second file does not return any data.
demo_mail.begin_attachment(conn => conn,mime_type => v_mime_type_bin,inline => TRUE,

                                   filename => filenm, transfer_enc => 'base64');


      fil := BFILENAME(dirname, filenm);

      file_len := dbms_lob.getlength(fil);

      dbms_output.put_line('file_len is '||file_len);

      modulo := mod(file_len, amt);

      pieces := trunc(file_len / amt);

      if (modulo <> 0) then

         pieces := pieces + 1;

      end if;

      dbms_lob.fileopen(fil, dbms_lob.file_readonly);, amt, filepos, buf);

      data := NULL;

      FOR i IN 1..pieces LOOP

         filepos := i * amt + 1;

         file_len := file_len - amt;

         data := utl_raw.concat(data, buf);

         chunks := trunc(utl_raw.length(data) / MAX_LINE_WIDTH);

         IF (i <> pieces) THEN

            chunks := chunks - 1;

         END IF;

          demo_mail.write_raw( conn => conn,

                                message => utl_encode.base64_encode(data ) );

            data := NULL;

         if (file_len < amt and file_len > 0) then

            amt := file_len;

         end if;
, amt, filepos, buf);

      END LOOP;




   demo_mail.end_attachment(conn => conn );

END begin_attachment;

Open in new window

Question by:DTOITW
  • 4
  • 3
LVL 73

Assisted Solution

sdstuber earned 500 total points
ID: 22751115
Your "demo_mail"  end_attachment  code needs to differentiate the mime delimiter for end one mime block and the end of the last mime block

LVL 73

Assisted Solution

sdstuber earned 500 total points
ID: 22751130
I'm assuming you have some sort of "begin mime block" procedure too probably something called "begin_attachment" or something like that.

you also need to specify in your email header 'multipart/mixed; boundary="--some_unique_string'

Author Comment

ID: 22755853
I have attcahed the complete code, as I do not understand how the mime delimiter works and how I should build a differentiation  into the mime block(begin / end attchment blocks?). The demo_mail code that I found and use does not seem to make provison for that in the end_attachment part.
The  'multipart/mixed; boundary=" is specified.
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

LVL 73

Accepted Solution

sdstuber earned 500 total points
ID: 22757905
can you post the code for demo_mail.begin_attachment  and demo_mail.end_attachment?

the general layout of mime blocks should be...

write mime boundary... || crlf
write mime content type || crlf
write  disposition inline/attachment/filename ||crlf
write data || crlf
write crlf
if last mime block then write mime boundary

LVL 73

Assisted Solution

sdstuber earned 500 total points
ID: 22757914
probably what is happening is your end_attachment assumes only one attachement ever so it writes the end boundary always.

Author Comment

ID: 22764807

HI here are the mail_demo being used with demo_mail.begin_attachment  and demo_mail.end_attachment

Author Closing Comment

ID: 31507090
The problem was a variable not reset properly befor doing the second attachment

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now