UTL_SMTP to send all the query result in one mail

Hello All,
I have a procedure for Oracle User Password Expiry Notification via mail using UTL_SMTP
Also, I have created a table (email_address) to store the email addresses
TableName: EMAIL_ADDRESS (username, email)
USERNAME
EMAIL
HR
[email protected]
SH
[email protected]
SAMPLE
[email protected]
TEST
[email protected]
My PL/SQL
declare
crlf VARCHAR2(2)  := chr(13)||chr(10);
CURSOR c1 IS SELECT
e.alternate_name,e.email,e.cc,u.expiry_date, round(u.expiry_date-sysdate) as date_diff
FROM dba_users u, email_address e
WHERE u.username=e.username;
username VARCHAR2(50);
email VARCHAR2(250);
expire_date varchar2(50);
date_diff  varchar2(50);
sender VARCHAR2(40) := '[email protected]';
message VARCHAR2(200);
mailhost VARCHAR2(30) := 'x.x.x.x'; 
mail_conn UTL_SMTP.connection;
BEGIN
message:=' user will expire in '; 
OPEN c1;
LOOP
FETCH c1 INTO username,email,expire_date,date_diff;
EXIT WHEN c1%NOTFOUND; 
mail_conn := UTL_SMTP.open_connection(mailhost, 25);
UTL_SMTP.helo(mail_conn, mailhost);
UTL_SMTP.mail(mail_conn, sender);
UTL_SMTP.rcpt(mail_conn, email);
UTL_SMTP.data(mail_conn, 'To: ' || email || crlf || 'Subject: ' || '[Test Mail]: Oracle User Password Expiry Reminder(user: '|| username ||')' || crlf || 'Password of ' || username||message||' '||date_diff||'days'||' (Expiry Date: ' || expire_date ||');
UTL_SMTP.quit(mail_conn);
END LOOP;
CLOSE c1;
END;
But when I execute the above PL/SQL, I am getting 4 different mails having each user password expiry information.
But I want all the user password expiry information in one mail.
Is it possible??

declare
crlf VARCHAR2(2)  := chr(13)||chr(10);
CURSOR c1 IS SELECT 
e.alternate_name,e.email,e.cc,u.expiry_date, round(u.expiry_date-sysdate) as date_diff 
FROM dba_users u, email_address e 
WHERE u.username=e.username;
username VARCHAR2(50); 
email VARCHAR2(250);
expire_date varchar2(50);
date_diff  varchar2(50);
sender VARCHAR2(40) := '[email protected]';  
message VARCHAR2(200);
final_message varchar2(1000);
mailhost VARCHAR2(30) := 'x.x.x.x';  
mail_conn UTL_SMTP.connection; 
BEGIN 
message:=' user will expire in ';  
OPEN c1; 
LOOP 
FETCH c1 INTO username,email,expire_date,date_diff; 
EXIT WHEN c1%NOTFOUND;  
   final_message := final_message || 'user: '|| username ||')' || crlf || 'Password of ' || username||message||' '||date_diff||'days'||' (Expiry Date: ' || expire_date || '): ';
END LOOP; 
CLOSE c1;
mail_conn := UTL_SMTP.open_connection(mailhost, 25); 
UTL_SMTP.helo(mail_conn, mailhost);
UTL_SMTP.mail(mail_conn, sender); 
UTL_SMTP.rcpt(mail_conn, email);
UTL_SMTP.DATA(mail_conn, 'To: ' || email || crlf || 'Subject: ' || '[Test Mail]: Oracle User Password Expiry Reminder('||final_message||')';
UTL_SMTP.quit(mail_conn);
END;

Similar Messages

  • How to make my computer send all the audio through optical audio cable instead of headphone jack?

    Howdy,
    To listen to online radios or CD's played from my computer, I used to connect the computer to my home entertainment system from the computer's headphone jack to the AUX port on my home entertainment system.
    I now wanted to get better sound and purchased the optical audio cable. However, I don't know how to tell my computer to send the audio signal to the home entertainmeny system through the optical digital cable rather than through the headphone jack. If I just unplug the cable connecting the headphone jack and the AUX port and only have the PC and the system connected with the optical audio cable, I don't hear any sounds. I suspect the computer isn't sending any data through the optical audio port. I'm not able to find how I can adjust the settings on my computer so that from now all sounds are output through the optical audio.
    1) I'd like to do that mainly for my HP desktop (configuration below) and any advice on how to do that would be appreciated.
    2) I also have a HP laptop (configuration below) and was wondering if that would be doable too (even though it doesn't appear to have a audio out, but it has HDMI out - can one convert it to optical audio?
    Thanks in advance!
    My desktop is: 
    ENVY h8xt,
    • Windows 8 64
    • 3rd Generation Intel(R) Core(TM) i7-3770 quad-core processor [3.4GHz, 8MB Shared Cache]
    • 12GB DDR3-1333MHz SDRAM [3 DIMMs]
    • 1TB 7200 rpm SATA hard drive
    • No secondary hard drive
    • 1GB AMD Radeon HD 7570 [DVI, HDMI, DP, VGA adapter]
    • 300W Power supply
    • SuperMulti DVD Burner
    • Wireless-N LAN card (1x1)
    • 15-in-1 memory card reader, 2 USB 2.0 (front), 2 USB 3.0 (top)
    • No Additional Office Software
    • No additional Security Software
    • No TV Tuner
    • Beats Audio (tm) -- integrated studio quality sound
    • HP USB volume control keyboard and mouse with Win 8 keyboard
    • Adobe Premiere Elements & Photoshop Elements 10
    And the laptop:
    HP ENVY 15t Quad    
    • Windows 8.1 64
    • 4th generation Intel(R) Core(TM) i7-4700MQ Processor
    • NVIDIA(R) GeForce(R) GT 740M Graphics with 2048MB of dedicated video memory
    • 15.6-inch diagonal Full HD BrightView LED-backlit Display (1920x1080)
    • 8GB DDR3 System Memory (1 Dimm)
    • 1TB 5400 rpm Hard Drive
    • 24GB flash Hard Drive Acceleration Cache
    • No Additional Office Software
    • Security Software Trial
    • 6-Cell Lithium-Ion Battery
    • No Internal DVD or CD Drive
    • Standard Keyboard
    • HP TrueVision HD Webcam w/ integrated digital mic
    • 802.11 AC WLAN and Bluetooth(R) [2x2]
    This question was solved.
    View Solution.

    Hello @_goma,
    Welcome to the HP Forums, I hope you enjoy your experience! 
    I have read your post on how you are looking to make your computer send all the audio through an optical audio cable instead of the headphone jack, and I would be happy to assist you in this matter!
    To configure your desktop to enable the optical audio cable, I recommend following the steps below:
    Step 1. Click the Windows Key Button on your desktop
    Step 2. Type "Control Panel"
    Step 3. Select "Control Panel" in the top right-hand corner
    Step 4. Select Sound
    Step 5. Under the Playback tab, right-click the white area below the devices available
    Step 6. Select "Show Disabled" and "Show Disconnected Devices"
    Step 7. Connect your Optical Audio Cable
    Step 8. Select your Optical Audio Cable as the default device and click "Enable"
    Since it is not possible to convert the HDMI out to audio out on your notebook computer, it is unfortunate that the notebook is not able to connect with an optical audio cord.
    Please re-post with the results of your troubleshooting, and I look forward to your reply!
    Regards
    MechPilot
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the right to say “Thanks” for helping!

  • How to put variable selection and the query result the same screen

    Dear all,
       how can I put the variable selection and the query result in the same screen? Please advise. Thanks.
    Jin Ming

    Not sure if you are saying you want the prompts on the same page as the results... however in 7.0 with BEx Analyzer, you can insert a text object from the design toolbar and assign it to the variable.... this way, lets say you run query for period 6, then the text object will display "6" on the same area where the query results are.

  • Why does the Query Result display "X" as a result

    Hello All,
    I have a query in which there are 6 Characteristics and 1 calculated key figure. But when the query is executed the query result displays as "X" in the column against all the 6 characteristics.
    Can anybody provide solution as to why the result displays "X" as a result.
    Regards,
    Vikram

    Hello all,
    Everybody answered it correctly. But when i debugged the query, i did not get any calculation which is getting divided by 0 and there were no mixed units of measurements. Probably it was an erroneous transport earlier. I only created and request again and transported the query from dev and the query is running fine.
    Thanks everybody.
    Vikram

  • RPD - Cannot obtain number of columns for the query result :Working with MS SQL 2012 schema

    Hi All,
    I have created my warehouse in MS SQL 2012.
    For management purpose, I have created different schemas in SQL database
    In RPD, Physical layer, when i view data > I get error as
    [nQSError:16002] Cannot obtain number of columns for the query result.
    [nQSError:16001] ODBC error state : S0002 code : 208 message: [Microsoft][ODBC SQL Server Driver][SQL Server] Invalid object name 'tbl'..
    [nQSError:16001] ODBC error state : S0002 code : 208 message: [Microsoft][ODBC SQL Server Driver][SQL Server] Statements could not be prepared..
    I have already browsed : OBIEE 11g Strange ODBC Driver Error with SQL Server : Total Business Intelligence ... did not help me
    please help!!!

    Hi All,
    After all R&D it is been found that Oracle business administrator( RPD) needs default dbo schema. It doesn't accept custom schema for pulling data.
    If anybody have other views please share.!!
    Thank you

  • Using the client result cache without the query result cache

    I have constructed a client in C# using ODP.NET to connect to an Oracle database and want to perform client result caching for some of my queries.
    This is done using a result_cache hint in the query.
    select /*+ result_cache */ * from table
    As far as I can tell query result caching on the server is done using the same hint, so I was wondering if there was any way to differentiate between the two? I want the query results to be cached on the client, but not on the server.
    The only way I have found to do this is to disable all caching on the server, but I don't want to do this as I want to use the server cache for PL/SQL function results.
    Thanks.

    e3a934c9-c4c2-4c80-b032-d61d415efd4f wrote:
    I have constructed a client in C# using ODP.NET to connect to an Oracle database and want to perform client result caching for some of my queries.
    This is done using a result_cache hint in the query.
    select /*+ result_cache */ * from table 
    As far as I can tell query result caching on the server is done using the same hint, so I was wondering if there was any way to differentiate between the two? I want the query results to be cached on the client, but not on the server.
    The only way I have found to do this is to disable all caching on the server, but I don't want to do this as I want to use the server cache for PL/SQL function results.
    Thanks.
    You haven't provided ANY information about how you configured the result cache. Different parameters are used for configuring the client versus the server result cache so you need to post what, if anything, you configured.
    Post the code you executed when you set the 'client_result_cache_lag' and 'client_result_cache_size' parameters so we can see what values you used. Also post the results of querying those parameters after you set them that show that they really are set.
    You also need to post your app code that shows that you are using the OCI statements are used when you want to use client side result cacheing.
    See the OCI dev guide
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28395/oci10new.htm#sthref1491
    Statement Caching in OCI
    Statement caching refers to the feature that provides and manages a cache of statements for each session. In the server, it means that cursors are ready to be used without the need to parse the statement again. Statement caching can be used with connection pooling and with session pooling, and will improve performance and scalability. It can be used without session pooling as well. The OCI calls that implement statement caching are:
      OCIStmtPrepare2()
      OCIStmtRelease()

  • I am trying to get a good copy of my home video on DVD using IDVD.  On editing the video all the viewing screens show the video perfectly in HD.  When I burn the video to DVD all the end results are buzzy with squiggly lines.  Any fix?  Thanks?

    I am trying to get a good copy of my home video on DVD using IDVD.  On editing the video all the viewing screens show the video perfectly in HD.  When I burn the video to DVD all the end results are buzzy with squiggly lines.  Any fix?  Thanks?

    Hi
    There are several layers to this Q
    A. There are no HD in DVD - DVD is as standard only SD-Video what ever tools used to produce it !
    iDVD or DVD-Studio Pro or Roxio Toast™ - will only make SD-Video on DVD
    B. DVD can be better or worse
    • Using "Share to iDVD" is no good way - Better is Share to Media Browser and as Large (NOT HD as result will be worse)
    • Using iMovie'08 or 09 or 11 - are not tools to chose if highes quality is of importance - iMovie up to HD6 or FinalCut any version is far better as they send over all lines to iDVD and not only every second one.
    • Using Right encoder quality depending on movie and Manu duration is very important
    • Use of high quality brand of DVD - is important - I use Verbatim DVD-R
    • Type of DVD - DVD-R plays on more DVD-Players (even old ones)
    • Burn speed - I set it down to x4 - resulting in less burn errors - plays on more players
    • I secure a minimum of 25Gb free space on Start-Up Mac OS hard disk as iDVD and Mac OS needs this and it can not be taked from other hard disks - has to be here.
    • What You feed iDVD does matter
    Video codecs
    Audio file formats
    Photo file formats
    Yours Bengt W

  • How can I export the query result into access(*.mdb) file?

    Dear all:
    I want to export the query result displayed in jsp into excel file
    and access file. And I have exported the result into excel format successfully, only one line should be added in the head of Jsp:
    <%@ page contentType="application/vnd.ms-excel; charset=gb2312" %>
    But how can I export it in access(*.mdb) file? I have replaced "excel"
    with "access". But it can't achive my goal.
    What should I do to achieve my goal?
    Thanks!

    The only reason your Excel export works is that Excel knows how to interpret comma separated values as an input file format. Access has no such beast.
    If you absolutely must provide info in an mdb, one solution would be to create an ODBC datasource pointing to an empty mdb, then push data into it using the jdbc:odbc bridge, then make a copy of the file and stream it down to the browser. You may run into some ugly file locking items here - set the ODBC connection so it is not shared, and that might help.
    This one is going to be ugly.
    I suppose another approach would be to write a simple VB applicatin that uses automation to create an MDB, then stream that file down to the browser from your servlet. That would almost certainly be faster than the ODBC approach.
    - K

  • How can i display all the query items to a table?

    how can i display all the query items to a table in a jsp file?
    i always have an out of memory error..

    any body??any idea?
    is it possible thru configuration or i have to write a program by the abaper??
    Biswa

  • How to get the query result of improvement (Before and After ) using sql de

    how to get the query result of improvement (Before and After ) using sql developer.

    Check
    http://www.oracle.com/technetwork/articles/sql/exploring-sql-developer-1637307.html

  • How do i turn off the option that sends all the messages i receive to all other linked to the same computer? on this

    how do you turn off the option that sends all the messages i send, when i send them who ever is linked to the same comuter is also getting all the messages. help

    don't share apple id or the email address linked to imessages. see in settings/messages.

  • How to display the query results in several pages?.

    Hi,
    i want to display the query results in several pages. for example my query result found 50 matches, now i want to print 20 per pages next 20 will be in next pages. iam using only jsp & mysql.
    Regards
    Chinna

    Hi, what you are trying accomplish is known as pagination.
    You could use JSTL tags with Custom Tags to perform pagination in your JSP pages.
    evnafets showed me DisplayTags , you could use those as well http://displaytag.sourceforge.net/11/tut_externalSortAndPage.html
    Here is one article on paging:
    http://www.javaworld.com/javaworld/jw-07-2004/jw-0726-pagination.html

  • Display the query result in an Excel file??

    hi there..
    am writing one script file that queries my DB and display the query result in an Excel file??
    i.e: if my query is :
    select col1, col2
    from table;
    and i want the results to dispalys in 2 col. in an Excel spreadsheet..
    Appreaciating ur cooperation..
    Mourad

    set colsep to a delimiter that is not normally part of your data like |
    also setup the environment with these other setup commands
    Set Echo Off;
    Set Concat Off;
    Set Pagesize 9999;
    Set Feedback Off;
    Set Verify Off;
    Set Term Off;
    Set Space 0;
    Set Colsep '|'
    Set Underline Off;
    If you wanted to use a comma delimiter the setup would be same but the set colsep='","'
    with the addition of concatenating a " on the first col and last col of the query
    eg.
    -- if first col and last_col are character types then
    SELECT '"'||col1,....,last_col||'"'
    FROM table;
    Otherwise if either is a number they would have to be converted with a TO_CHAR

  • During SQL query inserting a record - will it appear on the query result

    Hi,
    Oracle 10g SELECT-query executes ca 10 seconds and contains Joins over multiple tables in on database conenction.
    On execution 3rd second a new record is inserted in another database connection and commited to the database, the 3rd query satisgy the SELECT-Query fileters.
    Wil lthe inserted record on 3rd second appear on the query results?
    Thx.

    CharlesRoos wrote:
    Hi,
    Oracle 10g SELECT-query executes ca 10 seconds and contains Joins over multiple tables in on database conenction.
    On execution 3rd second a new record is inserted in another database connection and commited to the database, the 3rd query satisgy the SELECT-Query fileters.
    Wil lthe inserted record on 3rd second appear on the query results?
    Thx.In general Keith is right and a select will not see changes done and committed in a different session, that happend during the select. This is called READ CONSISTENCY. THis means a select will see the data from the exact time when it was called.
    However with database links in place read consistency can not be fully garanteed.
    See this explaination and solution from the 10g docs : http://docs.oracle.com/cd/B19306_01/server.102/b14231/ds_txnman.htm#i1008473

  • Query should fetch all the query details in the system.

    Hi All
    We  are looking for a query which will fetch all the query details in the system along with the user names either who has created the query or who has run it atleast once.
    If any of the queries are not used for a long time then we  can delete it with the user's/owner's approval.
    Is there anyway we can desing such query .
    Thanks
    Asim

    Hi,
    Thanks for the reply.
    My requirement is that we want to create a new query which should fetch the details information of already existing queries.
    Like who has created that query, how frequently the use it etc...
    Whenever we run the new query it should give information of all other existing queries.
    Thanks and Regards
    Asim

Maybe you are looking for