Sending email from database

Hello,
I created a procedure for sending email and it is working fine and i receive emails..
Only, I can't get the sender and the reciptient with the subject of the email.
CREATE OR REPLACE PROCEDURE send_mail
( sender IN VARCHAR2,
recipient IN VARCHAR2,
subject IN VARCHAR2,
message IN VARCHAR2)
IS
mailhost VARCHAR2(30) := 'send.columbia.edu';
mail_conn utl_smtp.connection;
crlf VARCHAR2( 2 ):= CHR( 13 ) || CHR( 10 );
mesg VARCHAR2( 1000 );
BEGIN
mail_conn := utl_smtp.open_connection(mailhost, 25);
mesg:= 'Date: ' || TO_CHAR( SYSDATE, 'dd Mon yy hh24:mi:ss' ) || crlf ||
'From: <'||sender||'>' || crlf ||
'Subject: '||subject || crlf ||
'To: '||recipient || crlf ||
'' || crlf || message;
utl_smtp.helo(mail_conn, mailhost);
utl_smtp.mail(mail_conn, '[email protected]');
utl_smtp.rcpt(mail_conn, '[email protected]');
utl_smtp.data(mail_conn, 'mesg');
utl_smtp.quit(mail_conn);
END;
thanks in advance,
Aysha,

I add the two lines before "utl_smtp.Quit(v_mail_conn);" in my procedure:
utl_smtp.write_data(mailCONN, 'CC: '||mailFROM || chr(13));
utl_smtp.write_data(mailCONN, 'BCC: '||mailFROM || chr(13));
DECLARE
v_From VARCHAR2(80) := '[email protected]';
v_Recipient VARCHAR2(80) := '[email protected]';
v_Subject VARCHAR2(80) := 'test subject';
v_Mail_Host VARCHAR2(30) := 'mail.mycompany.com';
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 ||
crlf ||
'some message text'|| crlf || -- Message body
'more message text'|| crlf
utl_smtp.write_data(mailCONN, 'CC: '||v_From || chr(13));
utl_smtp.write_data(mailCONN, 'BCC: '||v_From || chr(13));
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;
The procedure is compiled well, but by doing
execute send_mail(from_mail, to_mail,cc_mail,bcc_mail,subject, body);
I got 29277. invalid SMTP operation
cause: The smtp operation was invalid at the current stage of the smtp transaction
Thanks for your assistance,
Aysha

Similar Messages

  • Sending email from database version 8.0.5

    Hi!
    We are current using Oracle Database 8.0.5. How can we send email using PL/SQL?
    utl_smtp is not yet available i think for this database version? what is the alternative? How do we use/install this alternative.
    Please help. Thanks.
    Erick

    Here is our Oracle version from SQL*Plus:
    SQL> select * from v$version;
    BANNER
    Oracle8i Enterprise Edition Release 8.1.5.0.0 - Production
    PL/SQL Release 8.1.5.0.0 - Production
    CORE Version 8.1.5.0.0 - Production
    TNS for 32-bit Windows: Version 8.1.5.0.0 - Production
    NLSRTL Version 3.4.0.0.0 - Production
    I got this error from my procedure:
    PLS-00201: identifier 'UTL_SMTP.CONNECTION' must be declared
    Is this version not enough to run UTL_SMTP?

  • Is it possible to read , send emails from the database in oracle8.

    Hi,
    My present project needs me to send emails from the database through procedures. There is an oracle package UTL_HTTP in oracle8 which could be used to read emails from database. So kindly tell how to go about sending an email from the database. Is this feature available in Oracle8i.
    Thank you.

    Okay , Here's my Javascript wgich is in an onload process.
    Javascript variable addr_str displays the correct result.
    My hidden field is called P101_CHECKVAL.
    <html>
    <title>CodeAve.com(JavaScript: Display All URL Variables)</title>
    <body bgcolor="#FFFFFF">
    <script language="JavaScript">
    <!--
    // Create variable is_input to see if there is a ? in the url
    var is_input = document.URL.indexOf('P101_CHECKVAL:');
    // Check the position of the ? in the url
    if (is_input != -1)
    // Create variable from ? in the url to the end of the string
    addr_str = document.URL.substring(is_input+1, document.URL.length);
    // Loop through the url and write out values found
    // or a line break to seperate values by the &
    for (count = 0; count < addr_str.length; count++)
    if (addr_str.charAt(count) == "&")
    // Write a line break for each & found
    {document.write ("<br>");}
    else
    // Write the part of the url
    {document.write (addr_str.charAt(count));}
    // If there is no ? in the url state no values found
    else
    {document.write("No values detected");}
    -->
    </script>
    </body>
    </html>
    Everytime I put the HTML_get code into the javascript, it basically tells me I have an error on the page. So what exactly do I put that sets P101_CHECKVAL equal to the value of addr_str?

  • Cannot send email from Exchange 2007 to Exchange 2013 - Coexistence

    Existing Exchange 2007 SP3 1 MBX, 2 CAS/HT, 2 ET servers.
    I have added an Exchange 2013 server with MBX/CAS role.
    Email will flow from Ex2013 server no problem.  Mail from Ex2007 systems cannot deliver to Ex2013 boxes, it dies in queue with a 4.4.7 expired message after issuing a delay message.
    I can telnet to ports 25, 587,717,465,475, and 2525 from Ex2007 HT role to new Exchange 2013 server.  I can send email from Ex2007 HT role server to new Exchange 2013 server using telnet to port 25.
    A ‘get-mailbox’ from the Ex2007 HT role server returns the server and database properly on the test users on Exchange 2013 server.
    The only strange thing I am seeing is from the Ex2007 systems, a ‘get-exchange server’ command shows the new Ex2013 server as role ‘16439’ which looks to perhaps be normal.
    Why is email not flowing to the new users on Exchange 2013?

    You should have exchange server authentication ticked in Default Receive connector in Exchange2007.
    Exchange 2007 and Exchange 2013 in the same subnet/network. if not please check any spam agent running between the networks. Are you running antispam on Exchange2013 ?
    MAS

  • Cannot Send Email from SAP Business One

    Hi Experts
    I have configured SAP Email Services from the Mailer Service and Customer can send emails all the while,
    Now I have an Issue for One User,
    Iam using the Same Machine, Same Database with Manager Login, I can send Email from SAP with Attachments
    But When I use another Super user the system is not delivering the Email and it Goes to the Sent box (but not delivered)
    Have anyone encountered the Issue before
    Please hep to solve this issue permanently
    Thanks and Regards
    Vinodh Kumar Mohan

    Hi Vinodh Kumar Mohan,
    If the email can be found in Sent box, it must be delivered already.
    The problem could be on the email recipient side. It may go to the junk mail.
    Thanks,
    Gordon

  • Send email from the server

    I need to send email from the database.
    Two ways that I am familiar with -
    1. using VB/ODBC controls;
    2. dbms_pipe
    Anyone knows a more 'direct' solution?
    Regards
    Anatoliy Smirnov
    null

    by the way how can u send attchments with mails from database.
    chetan
    try this...(thanks for the subject line help)
    the first message line will be read by non MIME compliant readers, the second message line with be in the body of the note, the nest 2 (third and fourth) will come in as attachments ( text ). Change the Content-type for things like word docs or other 8bit docs (Content-type: application/msword) and write_raw_data for the 8Bit parts
    CREATE OR REPLACE PROCEDURE send_mail_test (sender IN VARCHAR2,
    recipient IN VARCHAR2, subject IN VARCHAR2,
    message IN VARCHAR2)
    IS
    mailhost VARCHAR2(30) := 'smtp.naxs.net';
    mail_conn utl_smtp.connection;
    cv_cCRLF VARCHAR2(10) := UTL_TCP.CRLF;
    lv_message varchar2(4000);
    BEGIN
    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, recipient);
    utl_smtp.open_data(mail_conn);
    utl_smtp.write_data(mail_conn,'From: ' | | sender | | cv_cCRLF);
    utl_smtp.write_data(mail_conn,'To: ' | | recipient | | cv_cCRLF);
    utl_smtp.write_data(mail_conn,'Subject:' | | subject | | cv_cCRLF);
    utl_smtp.write_data(mail_conn,'MIME-Version: 1.0' | | cv_cCRLF);
    utl_smtp.write_data(mail_conn,'Content-Type: multipart/mixed; ');
    utl_smtp.write_data(mail_conn,'boundary="NextPart_000_01C002D3.EB460626"' | | cv_cCRLF);
    utl_smtp.write_data(mail_conn, cv_cCRLF | | message| |' first mess part'| | cv_cCRLF);
    utl_smtp.write_data(mail_conn,'--NextPart_000_01C002D3.EB460626' | | cv_cCRLF);
    utl_smtp.write_data(mail_conn, cv_cCRLF | | message| | ' second mess part'| | cv_cCRLF);
    utl_smtp.write_data(mail_conn,'--NextPart_000_01C002D3.EB460626' | | cv_cCRLF);
    utl_smtp.write_data(mail_conn,'Content-Type: text/plain; charset=us-ascii'| | cv_cCRLF);
    utl_smtp.write_data(mail_conn, cv_cCRLF | | message| | ' third mess part'| |cv_cCRLF);
    utl_smtp.write_data(mail_conn,'--NextPart_000_01C002D3.EB460626' | | cv_cCRLF);
    utl_smtp.write_data(mail_conn,'Content-Type: text/plain; charset=us-ascii'| | cv_cCRLF);
    utl_smtp.write_data(mail_conn, cv_cCRLF | | message| | ' fourth mess part'| |cv_cCRLF);
    utl_smtp.write_data(mail_conn,'--NextPart_000_01C002D3.EB460626--' | | cv_cCRLF);
    utl_smtp.close_data(mail_conn);
    -- utl_smtp.data(mail_conn, message);
    utl_smtp.quit(mail_conn);
    EXCEPTION
    WHEN OTHERS
    THEN
    DECLARE
    error_code NUMBER := SQLCODE;
    error_msg VARCHAR2(2000) := SQLERRM;
    error_info VARCHAR2(30);
    BEGIN
    DBMS_OUTPUT.PUT_LINE('We have an error: '| |error_code| |' '| |error_msg);
    END;
    END;
    show errors;
    null

  • ACL error when sending email from Oracle 11g

    Hi,
    It returned something like "error...ACL security" when I tried to send email from Oracle 11g. Is there any security thing that I need to release in Oracle 11g? I used to send emails from Oracle 10g and didn't find any problem.
    Thanks.
    Andy

    In Database 11g Oracle introduced Network Access Control Lists (ACLs) to protect the database from users using the many internet-capable packages such as UTL_INADDR, UTL_HTTP, UTL_TCP, etc.
    Read all about it in the docs and look at the code demos here:
    http://www.morganslibrary.org/library.html
    under DBMS_NETWORK_ACL_...

  • Send mail from database

    Hi, i am trying to send mail from database i have create a database in mysql and the program will retreive the email and send it to the person.
    I have set the classpath in my window 98.
    But still cannot run
    Below is my source code;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.sql.*;
    import java.util.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.net.*;
    import java.text.*;
    import java.io.*;
    public class Emailer
         public static void sendMessage( String title,
         String email1,String email2, String message1)
         throws Exception     
    try
    String host = "192.9.201.28";
    Properties props = new Properties();
    props.put("mail.smtp.host", host);
    Session session = Session.getInstance(props, null);
    Message msg = new MimeMessage(session);
         InternetAddress [] address = null;
    address = InternetAddress.parse(email1);
         InternetAddress [] ccaddress = null;
         ccaddress = InternetAddress.parse(email2);
         String mailsenderaddr = "[email protected]";
         msg.setFrom(new InternetAddress(mailsenderaddr));
         msg.setRecipients(Message.RecipientType.TO, address);
         System.out.println(email1);
         msg.setRecipients(Message.RecipientType.BCC, ccaddress);
         System.out.println(email2);
         msg.setSubject(title);
         System.out.println(title);
         msg.setSentDate(new java.util.Date());
         msg.setText(message1);
         System.out.println(message1);
         Transport.send(msg);
    System.out.println("Mesage Send");
    catch (MessagingException mex)
    System.out.println("msg err:"+mex);
         public static void main(String[] argv) throws Exception     
         try {
         System.out.println("Loading Driver (with Class.forName)");
         Class.forName ("org.gjt.mm.mysql.Driver");
         System.out.println("Getting Connection");
         Connection conn = DriverManager.getConnection (
         "jdbc:mysql://192.9.201.40/test?user=testid&password=testpwd");     // user, passwd
         System.out.println("Creating Statement");
         Statement stmt = conn.createStatement();
         System.out.println("Executing Query");
         ResultSet rs = stmt.executeQuery("SELECT * FROM Reminder where Date_Remind='20050406'");
         System.out.println("Retrieving Results");
         int i = 0;
         while (rs.next()) {
              String title = rs.getString("Title");
              String message1 = rs.getString("Message");
              String date_remind = rs.getString("Date_Remind");
              String email1 = rs.getString("Email1");
              String email2= rs.getString("Email2");
    System.out.println("ROW " + ++i + ": " +
    title + "; " message1 ";" + date_remind + "; " + email1+ ";" + email2+ ";");
              sendMessage ( title, email1,email2, message1);
              rs.close();          // All done with that resultset
              stmt.close();     // All done with that statement
              conn.close();     // All done with that DB connection
         } catch (ClassNotFoundException e) {
                   System.out.println("Can't load driver " + e);
         } catch (SQLException e) {
              System.out.println("Database access failed "+ e);
    But there are still error in the following:
    msg error: javax.mail.NoSuchProviderException: No provider for SMTP
    Please help..
    Thank you

    Can you print the error message your getting. Are you able to print date_reminder, email1, email2 from your db.

  • Send email from oracle

    Dear member & developers
    I want to send e mail from oracle application. If anybody knows, how to do this. please write or send a sample application or forms or database sql. I don't restricted to any application version like 10g or 11g same as database...
    I seriously need it.
    Thanks in Advanced.

    As Francois indicated - there are multiple examples around the internet and in the forums. Any email solution you choose is going to require that you have access to a valid email server (SMTP, POP3, etc). Also, the solution is dependent on "Where" you want to send the email from. I prefer a database solution because this makes it available to your entire database application, but you can use a Java email method (using Forms PJC or Java Bean) or you can OLE link to Microsoft Outlook.
    Take a look at Send Email from the Database. I wrote this package based on the DEMO_MAIL package provided by Oracle (via OTN) and stream line things a bit. There is an example of how to use the package in the article.
    Take a look at Send email with HTML body and local file attachements article on Franscois's web site for an example of sending email from an Oracle Form using Java.
    If you need to use Outlook - search the forum. I don't consider this to be a reasonable method so I don't use it or recommend it. I'm sure it works fine for others, I just think being dependent on a application installed on the client is not a solid solution. That's just my opinion. ;-)
    I search through out the net. Didn't get any tutorial video or any working materiel. I disagree with this statement - I did a quick Google search and found many examples (no videos) and demo's.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • Sending emails from application

    Hello techies,
    I want to send emails from my application.
    Iam using java.net.*,java.util.*,java.io.*; packages upto now .
    I dont want to use javax.mail.* package.
    What is the alternative to my problem. Is there any package or class which is usefull to send mails????
    regards,
    ramu

    Sending email using SMTP and Java
    I was on a project a while ago where we needed to be able to send email notifications from the application to the administrator of the database whenever certain errors were trapped. This example shows you how. There are a few libraries that we will need to add in order to get started.
    Include the following in your project:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.text.*;     // Used for date formatting.
    After you have added the above libraries you are ready to start to get into the good stuff!
    The first step to be able to send email it to create a connection to the SMTP port that is listening. Most of the time the SMTP port for a server is usually 25 but check with your email administrator first to get the right port.
    Here is the code to make that initial connection:
    private Socket smtpSocket = null;
    private DataOutputStream os = null;
    private DataInputStream is = null;
    Date dDate = new Date();
    DateFormat dFormat = _
        DateFormat.getDateInstance(DateFormat.FULL,Locale.US);
    try
    { // Open port to server
      smtpSocket = new Socket(m_sHostName, m_iPort);
      os = new DataOutputStream(smtpSocket.getOutputStream());
      is = new DataInputStream(smtpSocket.getInputStream());
      if(smtpSocket != null && os != null && is != null)
      { // Connection was made.  Socket is ready for use.
        [ Code to send email will be placed in here. ]
    catch(Exception e)
    { System.out.println("Host " + m_sHostName + "unknown"); }
    Now that you have made the connection it is time to add the code to send off the email. This is pretty straight forward so I will add comments into the code sample itself.
    try                       
    {   os.writeBytes("HELO\r\n");
        // You will add the email address that the server
        // you are using know you as.
        os.writeBytes("MAIL From: <[email protected]>\r\n");
        // Who the email is going to.
        os.writeBytes("RCPT To: <[email protected]>\r\n");
        //IF you want to send a CC then you will have to add this
        os.writeBytes("RCPT Cc: <[email protected]>\r\n");
        // Now we are ready to add the message and the
        // header of the email to be sent out.               
        os.writeBytes("DATA\r\n");
        os.writeBytes("X-Mailer: Via Java\r\n");
        os.writeBytes("DATE: " + dFormat.format(dDate) + "\r\n");
        os.writeBytes("From: Me <[email protected]>\r\n");
        os.writeBytes("To:  YOU <[email protected]>\r\n");
        //Again if you want to send a CC then add this.
        os.writeBytes("Cc: CCDUDE <[email protected]>\r\n");
        //Here you can now add a BCC to the message as well
        os.writeBytes("RCPT Bcc: BCCDude<[email protected]>\r\n");
        sMessage = "Your subjectline.";
        os.writeBytes("Subject: Your subjectline here\r\n");
        os.writeBytes(sMessage + "\r\n");
        os.writeBytes("\r\n.\r\n");
        os.writeBytes("QUIT\r\n");
        // Now send the email off and check the server reply. 
        // Was an OK is reached you are complete.
        String responseline;
        while((responseline = is.readLine())!=null)
        {  // System.out.println(responseline);
            if(responseline.indexOf("Ok") != -1)
                break;
    catch(Exception e)
    {  System.out.println("Cannot send email as an error occurred.");  }I hope this has helped you out!
    [i code above code from someone else,  thanks to him, her ]

  • Help: how to send emails from FORMS?

    Are there simple steps to send emails from FORMS?
    Thank you in advance.
    Jimmy

    I'm sure there are many ways to send emails from Forms. Personally I never had to do this, but I can imagine following ways.
    a) use UTL_SMTP-Package to send the email via your database
    b) use a Java-Call
    Peter

  • Cannot send email from yahoo account on iPhone 5

    I just got an iPhone5 and I couldn't set up my Yahoo email as "yahoo"--it would not allow me to complete the process despot multiple attempts. I had to set it up as an "other" account. I can receive and read emails on my phone, but when I reply those messages will not send. They go to the outbox and an error message pops up that says" the email account has been rejected by the server" Does anyone have advice on either issue: setting up yahoo properly and/or sending email from phone?

    outgoing mail server
    SMTP - Yahoo! SMTP Server
    primary server
    Yahoo! SMTP server - ON
    server port 465
    That's what I have for my yahoo account.

  • Cannot send email from non .mac server

    I am only able to send/reply emails using my .mac address. My 2 other server addresses keep giving me the following message.
    "Cannot send mail. One of the recipient addresses was invalid".
    How can I fix this?

    You should be able to send email from Safari, however I do wonder why you wish to do this and whether there is something inherently wrong with using your mail app and your iCloud address.

  • Cannot send email from MobileMe account

    Apple recently pushed out an update to the MobileMe calendar. Since upgrading my account, I am unable to send emails from Firefox4 (current version) in Windows. The page sits indefinitely at a loading screen. Apple Support won't help because it isn't an issue with Safari. Anyone else have this issue?

    When using the MobileMe account preset to create the account, the SMTP server is created with 587 as the SMTP server port, which can't be changed when using the MM account preset to create the account.

  • Cannot send email from an iPhone to a Outlook group.

    Hi,
    My question is simple and I'd like an exactly same answer : Can iPhone users send emails from their iPhone's to one or more groups created in Outlook?
    This is my situation: our organization is using iPhone to provide email, calendar, contact, task etc. to some of their employees. We are using Airwatch MDM Agent on user's iPhone because we have an Airwatch server in place. I have an user and she has an iPhone 5 and she has created some groups in Outlook but these groups are not reflected in her Contacts in the iPhone. I have update her phone with the latest update, although I was almost sure that this was not the issue, then I've found some interesting posts on internet saying that this was a known problem for the users with the previous iOS but I thought this might has been corrected with the iOS, apparently not.
    Also I've tried ''the trick'' that is posted on several forums with the iCloud but neither so it's working. I am looking for a straight answer, if this works or not on iPhone's?
    Thanks,
    Sebastian.

    There indeed ARE apps in the app store that will do what you want.  Just search and find the one that best fits your needs.

Maybe you are looking for

  • My camera is not being recognized on my macbook air

    I just got a new macbook air (older version).  I updated all the software and it says there is no camera recognized.

  • Problem downloading purchased movie from itouch

    I purchased two movies from itunes and one downloaded without a problem. The other movie will not download. I keep getting download error message and am unable to get it downloaded.

  • Flash playing slow in Adobe Connect 8 Content

    We are being upgraded to Adobe Connect 8 next week.  WE have a temporary Adobe Connect 8 and playing with it we find that when we load a flash file intro a Content area, it gives us the standard URL but if you try to play the video it just does not s

  • Production collective order serial number

    Hello guys, Could anyone please help me in finding  serial number of a parent collective order(production order) from a collective order(production order) number(AUFNR). All I'm trying is to print serial number from parent collective order in a child

  • Cannot install SharePoint Designer 2013

    I have been trying to install SharePoint Designer 2013 and get the following message: Microsoft Office 2013 does not support upgrading from a preview version of Microsoft Office 2013. You must first uninstall these preview versions of Microsoft Offic