Hi,

The following is my code to send email through smtp to one email address.

create or replace procedure send_email as
mailhost VARCHAR2(30) := 'smtp.mooks.com';
crlf VARCHAR2( 2 ):= CHR( 13 ) || CHR( 10 );
mesg VARCHAR2(1000);
mail_conn utl_smtp.connection;
BEGIN
mail_conn := utl_smtp.open_connection(mailhost, 25);
utl_smtp.helo(mail_conn, mailhost);
utl_smtp.mail(mail_conn, '');
utl_smtp.rcpt(mail_conn, '');
mesg := 'This is a test mail!' || crlf ||
'Subject: Just testing';
utl_smtp.data(mail_conn, mesg);
utl_smtp.quit(mail_conn);
END;


1. May I now how to use in-coperate a cursor to select the email address that I wish to send to using the following procedures please?

2. Besides a cursor, any way to test that the code above can send to 2 identified recipients?

3. How to specify the "TO: " column in the email? I do not want it to be inside the message like:
mesg := 'Date: ' || TO_CHAR( SYSDATE, 'dd-Mon-yy hh24:mi:ss' ) || cr ||
'From: <'||sender||'>' || cr ||
'Subject: '||subj || cr ||
'To: '||recipient || cr ||
'' || cr || msg;

The output of the above will be inside the message, instead of our normal message to specify To: , FRom:, Subject: columns.

Any help please?? Thanks!