GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Tech FAQs  >  PL/SQL
Go To First  |  Previous Question  |  Next Question 
 PL/SQL  |  Question 153 of 166    Print  
Send Email from Oracle Procedure
How to send Email via PL/SQL Procedure?


  
Total Answers and Comments: 1 Last Update: November 24, 2008     Asked by: p_pramanik123 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
November 24, 2008 05:12:29   #1  
rajivgupta780184 Member Since: August 2008   Contribution: 32    

RE: Send Email from Oracle Procedure

rem -----------------------------------------------------------------------
rem Filename: smtp.sql
rem Purpose: Send e-mail messages from PL/SQL
rem Notes: From Oracle8i release 8.1.6 one can send e-mail messages
rem directly from PL/SQL using either the UTL_TCP or UTL_SMTP
rem packages. JServer needs to be installed and configured.
rem Pont the IP Address to your local SMTP (Simple Mail
rem Transport) Server. No pipes or external procedures are
rem required.
rem Date: 24-nov-2008
rem Author: Rajiv Gupta
rem -----------------------------------------------------------------------

CREATE OR REPLACE PROCEDURE SEND_MAIL (
msg_from varchar2 : 'oracle'
msg_to varchar2
msg_subject varchar2 : 'E-Mail message from RAJIV'
msg_text varchar2 : '' )
IS
c utl_tcp.connection;
rc integer;
BEGIN
c : utl_tcp.open_connection('127.0.0.1' 25); -- open the SMTP port 25 on local machine
dbms_output.put_line(utl_tcp.get_line(c TRUE));
rc : utl_tcp.write_line(c 'HELO localhost');
dbms_output.put_line(utl_tcp.get_line(c TRUE));
rc : utl_tcp.write_line(c 'MAIL FROM: '||msg_from);
dbms_output.put_line(utl_tcp.get_line(c TRUE));
rc : utl_tcp.write_line(c 'RCPT TO: '||msg_to);
dbms_output.put_line(utl_tcp.get_line(c TRUE));
rc : utl_tcp.write_line(c 'DATA'); -- Start message body
dbms_output.put_line(utl_tcp.get_line(c TRUE));
rc : utl_tcp.write_line(c 'Subject: '||msg_subject);
rc : utl_tcp.write_line(c '');
rc : utl_tcp.write_line(c msg_text);
rc : utl_tcp.write_line(c '.'); -- End of message body
dbms_output.put_line(utl_tcp.get_line(c TRUE));
rc : utl_tcp.write_line(c 'QUIT');
dbms_output.put_line(utl_tcp.get_line(c TRUE));
utl_tcp.close_connection(c); -- Close the connection
EXCEPTION
when others then
raise_application_error(
-20000 'Unable to send e-mail message from pl/sql because of: '||
sqlerrm);
END;
/
show errors

-- Examples:
set serveroutput on

exec send_mail(msg_to >'rajivgupta780184@gmail.com');

exec send_mail(msg_to >'rajivgupta780184@gmail.com' -
msg_text >'Look I can send mail from plsql' -
);


Thanks & Regards
RAJIV GUPTA
Yogik Technologies pvt. ltd.


 
Is this answer useful? Yes | No

 Related Questions

Latest Answer : 1)Using DBMS_JOB package,we can schedule the job.There are number of built-in functions in that package to schedule a job.Ex:DBMS_JOB .SUBMITDBMS_JOB .RUN.2) Using DBMS_SCHEDULERTHIS I SYNTAX FOR CREATING JOBdbms_scheduler.create_job(ob_name             ...
Read Answers (6) | Asked by : kishorebabu

Latest Answer : %type will use for to define at column level.%rowtype is used to define for one or more than one columns ( like row or record or tuple ) means its user define type which hold one or more than one columns along with it. and generally it used with Cursor. ...

Can we call a procedure into another procedure?If yes means how you can pass the perameters for the two procedures?

Latest Answer : First create a Trigger and with Procedure you insert records.The :new will take the new values.So use Triggers in Procedures. ...
Read Answers (1) | Asked by : p

Latest Answer : Yes we can relate two tables from 2 diff usersE.g. if user A has table Ta  and User B has Table Tb  and Table Tb is child table and needs foreign key on A.Ta  then we need to grant "references" object privillege to User B on table ...
Read Answers (1) | Asked by : Shankar

Latest Answer : Two types of trigger are there1. Row level trigger2. Statement level trigger ...
Read Answers (7) | Asked by : GIRISH H.R.

Latest Answer : no difference ...
Read Answers (9) | Asked by : Suyog

What are the different types of collections supported in Oracle?PL/SQL datatypes TABLE and VARRAY, allow us to declare the collections nested tables, associative arrays, and variable-size arrays.

How do i write a function that returnsmore than 1 records from a tablefor example in sql server there is a solution as create function f1() return table asselect * from emphow do i do the same in oracle. plz help

How to return multiple records from procedure?e. g. I fired a select query and I want to retun a result to ?


 Sponsored Links

 
Related Articles

Querying Data with Oracle XQuery

Querying Data with Oracle XQuery Starting with Oracle Database 10g Release 2 you can take advantage of a full featured native XQuery engine integrated with the database With Oracle XQuery you can accomplish various tasks involved in developing PHP Oracle XML applications operating on any kind of dat
 

Using Oracle XML DB Repository

Using Oracle XML DB Repository Another variation on accessing and manipulating XML content stored in Oracle database is provided by Oracle XML DB repository which is an essential component of Oracle XML DB mosgoogle NOTE Oracle XML DB repository also known as XML repository is a hierarchically organ
 

Using Oracle Database for Storing, Modifying, and Retrieving XML Data

Using Oracle Database for Storing Modifying and Retrieving XML Data With Oracle XML DB you have various XML storage and XML processing options allowing you to achieve the required level of performance and scalability One of the most interesting things about Oracle XML DB is that it allows you to per
 

XML Processing in PHP and Oracle Applications

Processing XML in PHP Oracle Applications As mentioned there are two alternatives when it comes to performing XML processing in your PHP Oracle application You can perform any required XML processing using either PHP s XML extensions or PEAR XML packages or Oracle s XML features mosgoogle In the fol
 

PHP Oracle Web Development

PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax The book is written by Yuli Vaseliev a well known author of different web development and programming books PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax is a good starting b
 

Getting Started with Oracle and ODP.NET

ODP NET Developer’ s Guide by Jagadish Chatarji Pulakhandam Sunitha Paruchuri A practical guide for developers working with the Oracle Data Provider for NET and the Oracle Developer Tools for Visual Studio 2005 Application development with ODP NET Dealing with XML DB using ODP NET Oracle
 

PHP Oracle Web Development Review

PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax The book is written by Yuli Vaseliev a well known author of different web development and programming books The author is also an expert in open source technologies and SOA Service Oriented Architecture But besides
 

Step by Step Oracle PL-SQL Tutorial

This introductory tutorial to PL SQL will help you to understand the basic concepts of PL SQL Please review the following tutorials and practice the sample SQL Statements on your local Oracle Database Please note that you must learn these basic things before we actually start getting in to Advanced
 

Working with XML in Oracle

Working with XML in Oracle Introduction to XML Extensive markup language is the language which presents data in a human readable form of text The data can be anything from a purchase order or a stock quote or weather radar or a flight schedule it can be represented using XML XML is very similar to H
 

What is Oracle Net Service

Oracle Net Services provides enterprise-wide connectivity solutions in distributed, heterogeneous computing environments. Oracle Net Services eases the complexities of network configuration and management, maximizes performance, and improves network diagnostic capabilities. Oracle Net, a component
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape