?
Solved

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

Posted on 2008-10-17
8
Medium Priority
?
700 Views
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 dbms_lob.read 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');
   BEGIN
      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);
      dbms_lob.read(fil, 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;
         dbms_lob.read(fil, amt, filepos, buf);
      END LOOP;
      dbms_lob.fileclose(fil);
   END;
    
   demo_mail.end_attachment(conn => conn );
END begin_attachment;

Open in new window

0
Comment
Question by:DTOITW
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 1000 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


0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 1000 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'
0
 

Author Comment

by:DTOITW
ID: 22755853
Sorry,
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.

SMTP-MAIL-Code.zip
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 74

Accepted Solution

by:
sdstuber earned 1000 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

0
 
LVL 74

Assisted Solution

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

Author Comment

by:DTOITW
ID: 22764807

HI here are the mail_demo being used with demo_mail.begin_attachment  and demo_mail.end_attachment
DEMO-MAIL.zip
0
 

Author Closing Comment

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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Pop culture is prime bait for hackers seeking to infect user’s computers and mobile devices with malicious malware. Hackers know exactly what the latest trends are online and know how to use them to their advantage.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses
Course of the Month15 days, 11 hours left to enroll

743 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