Link to home
Start Free TrialLog in
Avatar of DTOITW
DTOITW

asked on

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

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

SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DTOITW
DTOITW

ASKER

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
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DTOITW

ASKER


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

ASKER

The problem was a variable not reset properly befor doing the second attachment
thanks