Home » SQL & PL/SQL » SQL & PL/SQL » How to send email through PL/SQL (Oracle)
How to send email through PL/SQL [message #361416] Wed, 26 November 2008 05:51 Go to next message
surit.patel
Messages: 5
Registered: November 2008
Location: Mumbai
Junior Member

Dear All,

Pls. give me help

How to send email through PL/SQL

Regards,
Surit.
Re: How to send email through PL/SQL [message #361418 is a reply to message #361416] Wed, 26 November 2008 05:53 Go to previous messageGo to next message
Michel Cadot
Messages: 64131
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Maybe just searching BEFORE posting for this question asked about a zillion times?
Or even searching for "mail" in documentation, maybe.

Regards
Michel
Re: How to send email through PL/SQL [message #361533 is a reply to message #361416] Wed, 26 November 2008 16:17 Go to previous messageGo to next message
mfouwaaz
Messages: 2
Registered: November 2008
Location: Vancouver, Canada
Junior Member
This could be a starting point. Please let me know if you need further help and I'd only be too happy to do so. Good Luck!

l_connection UTL_SMTP.CONNECTION;
crlf      CONSTANT VARCHAR2(2):= CHR(13) || CHR(10);
l_sender VARCHAR2(100) := 'sender_address@xyz.com';
l_subject VARCHAR2(100) := 'Subject of email';
l_recipient VARCHAR2(100) := 'receiving_address@pqr.com'
BEGIN
l_connection := UTL_SMTP.OPEN_CONNECTION('my_email_server.abc.com',25);
UTL_SMTP.HELO(l_connection,'my_email_server.abc.com');
UTL_SMTP.MAIL(l_connection,l_sender);
UTL_SMTP.RCPT(l_connection,l_recipient);
UTL_SMTP.open_data(l_connection);
UTL_SMTP.write_data(l_connection, 'Date: ' || TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS') || Chr(13));
UTL_SMTP.write_data(l_connection, 'From: ' || l_sender || Chr(13));
UTL_SMTP.write_data(l_connection, 'Subject: ' || SUBJECT || Chr(13));
UTL_SMTP.write_data(l_connection, 'To: '  || l_recipient || Chr(13));
UTL_SMTP.write_data(l_connection, '' || Chr(13));
UTL_SMTP.write_data(l_connection, MESSAGE_IN || Chr(13));
UTL_SMTP.close_data(l_connection);
UTL_SMTP.QUIT(l_connection);
END;
Re: How to send email through PL/SQL [message #361551 is a reply to message #361533] Wed, 26 November 2008 23:08 Go to previous messageGo to next message
Michel Cadot
Messages: 64131
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Depending on the version (that OP did not think it is important to post) there is a package to directly mail without knowing all the smtp stuff.

Regards
Michel
Re: How to send email through PL/SQL [message #362549 is a reply to message #361533] Wed, 03 December 2008 00:16 Go to previous messageGo to next message
aviva4500
Messages: 122
Registered: July 2008
Location: bangalore
Senior Member
Hi,
Can you post some links for sending a mail through pl/sql.

Thanks & Regards,
Hammer
Re: How to send email through PL/SQL [message #362560 is a reply to message #362549] Wed, 03 December 2008 00:52 Go to previous message
Michel Cadot
Messages: 64131
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Did you even search before posting this question?

Regards
Michel
Previous Topic: ORA-00932: inconsistent datatypes: expected - got CLOB
Next Topic: How to load the flat files data to database?
Goto Forum:
  


Current Time: Wed Dec 07 14:17:32 CST 2016

Total time taken to generate the page: 0.18996 seconds