Re: How to send pdf as attachment with email in oracle

From: <sunnychadha.90_at_gmail.com>
Date: Tue, 28 May 2019 04:56:10 -0700 (PDT)
Message-ID: <3bac42a8-5bd2-4131-a260-f689260e733c_at_googlegroups.com>


On Monday, 26 January 2015 23:29:56 UTC+5:30, Mladen Gogala wrote:
> On Mon, 26 Jan 2015 02:00:55 -0800, wE|rd0 wrote:
>
> > I am successfully receiving email through Oracle but opening the pdf
> > file, I get the error:-
> > "Adobe Reader could not open "ExistingFile.pdf" because it is either not
> > a supported file type or because the file has been damaged(for example,
> > it was sent as an email attachment and wasn't correctly decoded).
> >
> > Below is the code that I am using:-
> >
> > create or replace PROCEDURE mail_attachments_new
> >
> > AS
> > v_From VARCHAR2(80) := 'payslip_at_companyname.com'; v_Recipient
> > VARCHAR2(80) := 'amir.diwan_at_companyname.com';
> > v_Subject VARCHAR2(80) := 'test subject';
> > v_Mail_Host VARCHAR2(30) := '193.10.10.3';
> > v_Mail_Conn utl_smtp.Connection;
> > crlf VARCHAR2(2) := chr(13)||chr(10);
> >
> > BEGIN
> >
> > v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25);
> >
> > utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
> >
> > utl_smtp.Mail(v_Mail_Conn, v_From);
> >
> > utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
> >
> > utl_smtp.Data(v_Mail_Conn,
> > 'Date: ' || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf
> > ||
> > 'From: ' || v_From || crlf ||
> > 'Subject: '|| v_Subject || crlf ||
> > 'To: ' || v_Recipient || crlf ||
> >
> > 'MIME-Version: 3.1'|| crlf || -- Use MIME mail standard
> > 'Content-Type: multipart/mixed;'|| crlf ||
> > ' boundary="-----SECBOUND"'|| crlf ||
> > crlf ||
> >
> > '-------SECBOUND'|| crlf ||
> > 'Content-Type: text/plain;'|| crlf ||
> > 'Content-Transfer_Encoding: 7bit'|| crlf ||
> > crlf ||
> > 'some message text'|| crlf || -- Message body 'more message
> text'||
> > crlf ||
> > crlf ||
> >
> > '-------SECBOUND'|| crlf ||
> > 'Content-Type: application/pdf;'|| crlf ||
> > ' name="C:\Email\ExistingFile.pdf"'|| crlf ||
> > 'Content-Transfer_Encoding: base64'|| crlf ||
> > 'Content-Disposition: attachment;'|| crlf ||
> > ' filename="ExistingFile.pdf"'|| crlf ||
> > -- crlf ||
> > -- 'PDF,file,attachement'|| crlf || -- Content of attachment
> > -- crlf ||
> >
> > '-------SECBOUND--' -- End MIME mail
> >
> > );
> >
> > utl_smtp.Quit(v_mail_conn);
> > EXCEPTION
> > WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
> > raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
> >
> > END mail_attachments_new;
> >
> > Any ideas how to fix it?
> >
> > Dont have the option of attaching a file. Otherwise, I would have
> > attached the snapshot of the error.
>
> You should use UTL_MAIL, which has an option for adding attachments. The
> procedure name is SEND_ATTACH_RAW.
>
>
>
> --
> Mladen Gogala
> The Oracle Whisperer
> http://mgogala.byethost5.com
> Je suis Charlie

Hello Mladen,
[Quoted] I tried sending the pdf attachment using UTL_MAIL.send_attach_raw . But getting this error "Adobe Reader could not open "ExistingFile.pdf" because it is either not a supported file type or because the file has been damaged(for example, it was sent as an email attachment and wasn't correctly decoded). Please help me regarding this. Received on Tue May 28 2019 - 13:56:10 CEST

Original text of this message