Home » SQL & PL/SQL » SQL & PL/SQL » Send Email With Attachment (ORACLE 10.2.0.4.0, Windows)
Send Email With Attachment [message #420025] Wed, 26 August 2009 11:24 Go to next message
srini_thiru
Messages: 133
Registered: May 2008
Senior Member

Hi,

I like to know how to send email with attachment in oracle 10.2.0.4.0 version.

I came across some scripts in google but its not clear. How to set the path and filename for the attachment. Please share.

Thanks in Advance,
Seenu.
Re: Send Email With Attachment [message #420027 is a reply to message #420025] Wed, 26 August 2009 11:38 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
I came across some scripts in google but its not clear.

What make you think we make it clearer than the many full code posted?
Explain what you don't understand in the solution you found.

Regards
Michel
Re: Send Email With Attachment [message #420028 is a reply to message #420025] Wed, 26 August 2009 11:38 Go to previous messageGo to next message
BlackSwan
Messages: 25039
Registered: January 2009
Location: SoCal
Senior Member
You need to help us by following the Posting Guidelines as stated below.
http://www.orafaq.com/forum/t/88153/0/
Go to the URL above click the link "Posting Guidelines"
Go to the section labeled "Practice" & do as directed.

SEARCH works; use it!

http://www.orafaq.com/forum/?SQ=0&t=search&srch=mail+attachement&btn_submit=Search&field=all&forum_limiter=1& search_logic=AND&sort_order=DESC&author=
Re: Send Email With Attachment [message #420172 is a reply to message #420025] Thu, 27 August 2009 07:09 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
What's wrong with UTL_MAIL
Re: Send Email With Attachment [message #420177 is a reply to message #420025] Thu, 27 August 2009 07:27 Go to previous messageGo to next message
srini_thiru
Messages: 133
Registered: May 2008
Senior Member
I use the below script to send mail with attachment. But i don't know how to assign path for the attachment file.

create or replace procedure pr_mail_attachment is
v_From VARCHAR2(80) := 'mail@rediffmail.com';
v_Recipient VARCHAR2(80) := 'mail@rediffmail.com';
v_Subject VARCHAR2(80) := 'test subject';
v_mail_Host VARCHAR2(30) := '127.0.0.1';
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: 1.0'|| 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: text/plain;'|| crlf ||
' name="test.txt"'|| crlf ||
'Content-Transfer_Encoding: 8bit'|| crlf ||
'Content-Disposition: attachment;'|| crlf ||
' filename="test.txt"'|| crlf ||
crlf ||
'XLSX,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 pr_mail_attachment;

My Attachment file is in the path=c:/test/test.txt

Please help.

[Updated on: Thu, 27 August 2009 07:29]

Report message to a moderator

Re: Send Email With Attachment [message #420184 is a reply to message #420177] Thu, 27 August 2009 07:43 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
I say again - What's wrong with UTL_MAIL.

It does all this for you.
Re: Send Email With Attachment [message #420197 is a reply to message #420025] Thu, 27 August 2009 09:26 Go to previous messageGo to next message
srini_thiru
Messages: 133
Registered: May 2008
Senior Member


I checked with UTL_MAIL but i don't know how it will pick the path for the attachment of file.

Please let me know with an example. thanks for your help.

Re: Send Email With Attachment [message #420202 is a reply to message #420025] Thu, 27 August 2009 09:33 Go to previous messageGo to next message
BlackSwan
Messages: 25039
Registered: January 2009
Location: SoCal
Senior Member
http://www.google.com/search?btnG=1&pws=0&q=oracle+utl_mail+attachment
Re: Send Email With Attachment [message #420285 is a reply to message #420197] Fri, 28 August 2009 03:14 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
UTL_Mail doesn't use a path - you open the attachment you want, read the Raw / Varchar 2 data in and include it in your call to UTl_Mail
Previous Topic: Problem in Execute Immediate
Next Topic: problem in pl/sql code
Goto Forum:
  


Current Time: Mon Dec 05 20:51:59 CST 2016

Total time taken to generate the page: 0.16915 seconds