Failed to use sample code to send email

I tried to use the sample of 'sending email from the database with the utl_smtp package', the 2 packages were created successfully, but when I run the pl/sql block to call the stored procedure with:
BEGIN
demo_mail.mail(
sender => 'Me <[email protected]>',
recipients => 'Someone <[email protected]>, ' ||
'"Another one" <[email protected]>',
subject => 'Test',
message => 'Hi! This is a test.');
END;
I got the error:
ORA-29540: class oracle/plsql/net/TCPConnection does not exist.
The error explained is:
Cause: Java method execution failed to find a class with the indicated name.
Action: Correct the name or add the missing Java class.
May I know that how how I follow the action?
I manually installed Jserver by running the initJVM.sql following the instruction. But I still get the error. Maybe My question can be: where is the class class oracle/plsql/net/TCPConnection installed, and how can I add it.
I searched the dba_objects, the only objects similar is a JAVA CLASS '/d70c43a_TCPConnection'.
Minny
Thanks
MInny

you ust to download activation.jar and mail.jar and add them to your build path.
i have used the googlemail smtp server to send mail the code is following:
public void SendMail()
Properties props = new Properties();
props.put("mail.smtp.user", username);
props.put("mail.smtp.host", host);
props.put("mail.smtp.port", port);
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.socketFactory.port", port);
try{
     Authenticator auth = new SMTPAuthenticator(username,password);
Session session = Session.getInstance(props, auth);
MimeMessage msg = new MimeMessage(session);
msg.setText(text);
msg.setSubject(subject);
msg.setFrom(new InternetAddress(senderEmail));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress(receiver));
Transport.send(msg);
}catch(Exception ex) {
     System.out.println("Error Sending:");
System.out.println(ex.getMessage().toString());
and this the SMTPAuthenticator Class which you will need too.
class SMTPAuthenticator extends javax.mail.Authenticator {
     private String fUser;
     private String fPassword;
     public SMTPAuthenticator(String user, String password) {
     fUser = user;
     fPassword = password;
     public PasswordAuthentication getPasswordAuthentication() {
     return new PasswordAuthentication(fUser, fPassword);
     }

Similar Messages

  • Does any one have a sample code for sending email using IMAP ?

    Hi
    thank you for reading my post
    I have tried to use SMTP and because of some problems i could not use it and i must use Imap (authentication required)
    here is my SMTP code , does any one know how i can tune it to use Imap , or has a code snippet to send email using Imap ?
    thanks
    private static void postMail(String[] recipients, String subject, String message,
                             String from) throws MessagingException {
            boolean debug = false;
            class SMTPAuthenticator extends javax.mail.Authenticator
                    public PasswordAuthentication getPasswordAuthentication()
                        return new PasswordAuthentication(mail_usrname,mail_password);
            //Set the host smtp address
            Properties props = new Properties();
            FileInputStream fis;
            try {
                System.out.println("Loading property file");
                fis = new FileInputStream(new File("c:/email.properties"));
                props.load(fis);
                System.out.println("property file done");
            } catch (FileNotFoundException e) {
                System.out.println("file not found");
                e.printStackTrace();
            } catch (IOException e) {
                System.out.println("can not read properties file");
                e.printStackTrace();
            /*props.put("mail.smtp.user", mail_usrname);
    props.put("mail.smtp.host", smtpHost);
    props.put("mail.smtp.port", smtpPort);
    props.put("mail.smtp.starttls.enable","true");
    props.put("mail.smtp.socketFactory.port", smtpPort);
            // create some properties and get the default Session
            Authenticator auth = new SMTPAuthenticator();
            Session session = Session.getDefaultInstance(props, null);
            session.setDebug(debug);
            // create a message
            Message msg = new MimeMessage(session);
            // set the from and to address
            InternetAddress addressFrom = new InternetAddress(from);
            msg.setFrom(addressFrom);
            InternetAddress[] addressTo = new InternetAddress[recipients.length];
            for (int i = 0; i < recipients.length; i++) {
                addressTo[i] = new InternetAddress(recipients);
    msg.setRecipients(Message.RecipientType.TO, addressTo);
    // Setting the Subject and Content Type
    msg.setSubject(subject);
    msg.setContent(message, "text/HTML");
    System.out.println(msg.toString());
    Transport.send(msg);

    Please try this out!!!!!!!!!
    You can send emails using Outlook also. You can send email over Microsoft Exchange with this object (or another email server, using IMAP/POP).
    Sub SendMailOutlook(aTo, Subject, TextBody, aFrom)
    'Create an Outlook object
    Dim Outlook 'As New Outlook.Application
    Set Outlook = CreateObject("Outlook.Application")
    'Create e new message
    Dim Message 'As Outlook.MailItem
    Set Message = Outlook.CreateItem(olMailItem)
    With Message
    'You can display the message To debug And see state
    '.Display
    .Subject = Subject
    .Body = TextBody
    'Set destination email address
    .Recipients.Add (aTo)
    'Set sender address If specified.
    Const olOriginator = 0
    If Len(aFrom) > 0 Then .Recipients.Add(aFrom).Type = olOriginator
    'Send the message
    .Send
    End With
    End Sub

  • Writing a php code to send email link

    Hi guys-
    I have a php Fulfillment API that downloads a book. I want to write a code that sends an email (like one of those email address verification emails) with a random link that will run the code. I want to place the link in Paypal so that when a transaction is completed they get sent the email with the download link- Only problem- I just learned the term php- still don’t quite know what it means. Any thought of where I can start? I’m using cs6. Thanks in advance.

    Here is what php is:
    It is interpreted code that runs on your server.
    According to the folks that are responsible for it, "PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML."
    It is open source and free, so if your hosting provider does not support it, you need to change your hosting provider.
    But you have a fulfillment API (Application Programming Interface). You need to use sample code supplied with that API to create a script that will do what you want. Since you do not know php, you're looking at probably a month's worth of work in learning enough to be able to write in this scripting language, testing it and applying the sample code you have been supplied to do what you want.
    Go to http://us.php.net/  to learn how to use php or, better still, sign up for a course.
    Or hire a professional to build what you want.
    -Mark

  • Can I use DeliveryManager just to send email with no document?

    Can I use "oracle.apps.xdo.delivery.DeliveryManager" to just send email without any document attached? or
    Is this only used to deliver the documents by email?
    I just want to use DeliveryManager just to send email with content in the body of the email. I am using BI Publisher API.
    Can any of you provide sample input for the above?

    Hi,
    You can use iMovie to record the message and save it as an email sized item and send the file as email like before.
    For those iChat AV users without a Cam and the AIM users without a cam you can do One-Way Viedo chats.
    Once you have a recorded Video file you can also drop the file on any Buddies name in you iChat Buddy list rather than using email.
    For those using other services you can set up a Jabber account and enable the required Transport/Gateways and send the files that way.
    http://www.jabber.org.au/ichat = Australian Page
    AllForces
    These are the two main information pages on how iChat can connect to the other IM services.
    Jabber Public Server list
    That would appear to be everybody.
    Ralph

  • How to use java mail to send email to hotmail box

    how to use java mail to send email to hotmail box??
    i can send emails to other box(my company's email account) but for hotmail, the program didnt print any err or exception the recepient cant receive the mail.
    thanks

    you ust to download activation.jar and mail.jar and add them to your build path.
    i have used the googlemail smtp server to send mail the code is following:
    public void SendMail()
    Properties props = new Properties();
    props.put("mail.smtp.user", username);
    props.put("mail.smtp.host", host);
    props.put("mail.smtp.port", port);
    props.put("mail.smtp.starttls.enable","true");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.socketFactory.port", port);
    try{
         Authenticator auth = new SMTPAuthenticator(username,password);
    Session session = Session.getInstance(props, auth);
    MimeMessage msg = new MimeMessage(session);
    msg.setText(text);
    msg.setSubject(subject);
    msg.setFrom(new InternetAddress(senderEmail));
    msg.addRecipient(Message.RecipientType.TO, new InternetAddress(receiver));
    Transport.send(msg);
    }catch(Exception ex) {
         System.out.println("Error Sending:");
    System.out.println(ex.getMessage().toString());
    and this the SMTPAuthenticator Class which you will need too.
    class SMTPAuthenticator extends javax.mail.Authenticator {
         private String fUser;
         private String fPassword;
         public SMTPAuthenticator(String user, String password) {
         fUser = user;
         fPassword = password;
         public PasswordAuthentication getPasswordAuthentication() {
         return new PasswordAuthentication(fUser, fPassword);
         }

  • After installing the new Yosemite OS on my iMac I can no longer send email. I can receive email, but not send. I use gmail and can send email on the gmail (google) site, but not on "mail" on my iMac. Any others with this problem? What should we do?

    After installing the new Yosemite OS on my iMac I can no longer send email. I can receive email, but not send. I use gmail and can send email on the gmail (google) site, but not on "mail" on my iMac. Any others with this problem? What should we do?

    My gmail, which is correctly configured for Mail with gmail SMTP and Google IMAP, works for awhile on Mail, which I leave open while working on other applications. But several times a day I get msg from Google: "We recently blocked a sign-in attempt to your Google Account" . . . and requiring me to verify my account details, re-enter passwords, confirm security settings (or change them from "disable" to "enable less secure methods" and so on). In Mail I also have tried "taking all accounts online", and re-entering my gmail password inside Mail account settings. These steps successfully re-set comms between gmail and Mail ... for awhile, then it happens again. Enough occurrences over a work day that I just quit Mail and revert to accessing gmail directly. Apple Care advisor and an Apple knowledge base article say that Apple can't deal with this, as gmail is third-party app, and they refer me to gmail, and so far I've found nothing helpful there.
    From today I also have several instances of a window saying "Mail has unexpectedly closed" and asking me to Re-open it.
    I also use Yahoo mail, which stops working with Mac Mail at the same time as gmail, but I do not receive notices to re-verify from Yahoo.
    I recently upgraded from Mavericks to Yosemite. The Mail problem happened occasionally with Mavericks but is far more frequent with Yosemite.

  • Error Message when using Photoshop Element 9 sending email

    I was using Photoshop Element 9 sending email on Windows Live Mail.
    It was working perfect.
    A week ago, my computer had the problem and need to format and reinstall everything again.
    After that, when I used Photoshop Element 9 to send email using Windows Live Mail 2012.
    It came up error message in below:
    "Elements Organizer could not finish creating your E-mail message.
    Alternatively, you can use the Adobe E-mail Service via the Elements Organizer Preferences dialog."
    I don't want to use Adobe E-mail Service because it is very limited for email function such as attached another files or change email contents.
    Would you please give me some idea how to solve the problem ?
    Thanks,
    Joe

    Please refer the below link:
    http://forums.adobe.com/message/3284248#3284248
    http://helpx.adobe.com/photoshop-elements/kb/freeze-or-error-no-email.html
    -Harshit yadav

  • Sample code to send a mail from SAP

    Hi guys
    could any one provide me with the
    sample code to send a mail from SAP with text as the main body of that mail via bcs classes

    Hi,
         Please go through this code: U can send mail;
    Tables : zchp_cust-info.
    DATA: OBJCONT LIKE SOLISTI1 OCCURS 5 WITH HEADER LINE.
    DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.
    DATA: DOC_CHNG LIKE SODOCCHGI1.
    DATA: ENTRIES LIKE SY-TABIX.
    DATA: NAME(15).
    DATA: CON_NAME(20).
    DATA: req_num like zchp_cust_info.
    DATA: I_TAB_CHP LIKE ZCHP_CUST_INFO OCCURS 0 WITH HEADER LINE.
    *data: reno like ZCHP_CUST_INFO-req_num value .
    data input for the mail
    select * from zchp_cust_info
    appending table i_tab_chp where req_num = c_knumv.
    LOOP AT I_TAB_CHP.
    concatenate i_tab_chp-created_by i_tab_chp-req_num into CON_NAME.
    *WRITE: / con_name.
    ENDLOOP.
    Fill the document
    DOC_CHNG-OBJ_NAME = 'Refe'.
    DOC_CHNG-OBJ_DESCR = 'TESCRA Ref Number !'.
    DOC_CHNG-SENSITIVTY = 'P'.
    *OBJCONT = 'Tescra'.
    OBJCONT = CON_NAME.
    APPEND OBJCONT.
    OBJCONT = con_name.
    APPEND OBJCONT.
    DESCRIBE TABLE OBJCONT LINES ENTRIES.
    READ TABLE OBJCONT INDEX ENTRIES.
    DOC_CHNG-DOC_SIZE = ( ENTRIES - 1 ) * 255 + STRLEN( OBJCONT ).
    Fill the receiver list
    CLEAR RECLIST.
    RECLIST-RECEIVER = SY-UNAME.  " replace with <login name>
    RECLIST-REC_TYPE = 'B'.
    RECLIST-EXPRESS = 'X'.
    APPEND RECLIST.
    CLEAR RECLIST.
    RECLIST-RECEIVER = 'sapuser'.
    RECLIST-REC_TYPE = 'U'.
    APPEND RECLIST.
    Send the document
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
         EXPORTING
              DOCUMENT_TYPE  = 'RAW'
              DOCUMENT_DATA  = DOC_CHNG
              PUT_IN_OUTBOX  = 'X'
         TABLES
              OBJECT_CONTENT = OBJCONT
              RECEIVERS      = RECLIST
         EXCEPTIONS
              TOO_MANY_RECEIVERS         = 1
                   DOCUMENT_NOT_SENT          = 2
                  OPERATION_NO_AUTHORIZATION = 4
                   OTHERS                     = 99.
        CASE SY-SUBRC.
          WHEN 0.
            LOOP AT RECLIST.
              IF RECLIST-RECEIVER = SPACE.
                NAME = RECLIST-REC_ID.
              ELSE.
                NAME = RECLIST-RECEIVER.
              ENDIF.
              IF RECLIST-RETRN_CODE = 0.
                WRITE: / NAME, ': succesfully sent'.
              ELSE.
                WRITE: / NAME, ': error occured'.
              ENDIF.
            ENDLOOP.
          WHEN 1.
            WRITE: / 'Too many receivers specified !'.
          WHEN 2.
            WRITE: / 'No receiver got the document !'.
          WHEN 4.
            WRITE: / 'Missing send authority !'.
          WHEN OTHERS.
            WRITE: / 'Unexpected error occurred !'.
        ENDCASE.
    <b>Please provide points if the issue is solved.</b>
    Regards,
    Sunil

  • What to do about a virus that uses your mac to send email?

    what to do about a virus that uses your mac to send email?

    It's highly unlikely that your Mac has a virus, since no virus, worm or trojan has been reported, much less confirmed, as having the behavior you mention. As LB suggested, most likely it's your email account itself that has been compromised, or some other computer (a Windows system, almost certainly) that has your addresses on it has been infected.
    Check the "sent" folder for your email account and see if the bogus messages are shown there. If they are, that at least would verify that the emails were sent via your email account. Report back and let us know whether your email account is POP, IMAP or Exchange, and who your email host is.
    If the messages are not shown anywhere in your "sent mail" folder, then someone has almost certainly gotten hold of your contact list and spoofed your email address.
    Regards.

  • How many of you use CTRL + Enter to send email from Outlook

    It's a much faster option...and you don't have to grab that pesky mouse!

    I was working this morning and I asked my fiance if she used CTRL + Enter to send email from Outlook and she was not even aware that was an option. I have been using it for years and I wondered how many of you SpiceHeads use it as well?
    This topic first appeared in the Spiceworks Community

  • Ping all the servers into SP farm using powershell script and send email only if any of them failed to ping.

    Hi,
    i am trying to have such kind of functionality, so that if any servers in sharepoint farm failed then it will send notification email to specific user that server is not able to ping or failed. Right now following script is working but it sending mail either
    servers are all running or dead. But i would like to send email only if any of the server failed to ping. what i need to modify following code to work.
    Thanks in advanced
    #### Provide the computer name in $computername variable 
    $ServerName = "localhost","Dc-XX"  
    $smtp = "ExchChange" 
    $to = "[email protected]
    $from = "[email protected]
    $sub = " Server Status" 
    $body = @" 
    ##### Script Starts Here ######   
     foreach ($Server in $ServerName) { 
                        if (test-Connection -ComputerName $Server -Count 2 -Quiet ) {  
                            $body += write-output "$Server is alive and Pinging `n"  
                                } else { $body += Write-output "$Server seems dead not pinging `n"  
    $body 
    send-MailMessage -SmtpServer $smtp -To $to -Subject $sub -Body $body  -From $from   

    you need to put a check on the send-mailmessage if no ping fails then exit else send the email with message.
    also try this script, performing the the same thing but more granular way
    http://gallery.technet.microsoft.com/scriptcenter/d0670079-6158-4dc5-a9da-b261c70e4b7d#content
    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

  • Code to Use a button to send email in Java using NetBeans 4.1

    I am trying to use a JButton in Java to send an email to another recipient. I am relatively new to Java. Could someone send me the code?

    [url http://www.javacommerce.com/displaypage.jsp?name=javamail.sql&id=18274]Sending email from your java applications for idiots who do not know how to search

  • Is there any problem to use multiple threads to send email with JavaMail

    Dear all,
    I am using JavaMail 1.3.2 to send emails with SMTP, it works very well for a long time.
    But one day, I found that the email service hanged and I could never send email again until I restart the tomcat. I found that the reason was a deadlock had been created, the required resource for sending email had not been released.
    I guess the error is due to multiple threads are sending email at the same time. I made a test to create seperate thread for sending each email. After few days, I found this deadlock happened again. So, my question is: Can I use JavaMail with multiple threads? If not, I may need to sychronized all the thread that using JavaMail. I would like to make sure this is the reason for causing the deadlock problem.
    Here is part of my code for using JavaMail:
    transport = session.getTransport("smtp");
    transport.connect(email_host, smtp_user, smtp_pass);
    message.saveChanges();
    transport.sendMessage(message,message.getAllRecipients());
    which is very standard call, and it worked well for a long time.
    Here is part for my thread dump on tomcat:
    (Thread-339)
    - waiting to lock <0x5447c180> (a sun.nio.cs.StandardCharsets)
    (Thread-342)
    - locked <0x5447c180> (a sun.nio.cs.StandardCharsets)
    It seems that these happened after call the method transport.sendMessage() or message.updateChanges()
    , and the underlying implementation may require the JRE StandardCharsets object. But the object had been locked and never be released. So, the sendMessage() or updateChanges() can't be completed.
    Please give me some helps if you have any idea about it.
    Thanks very much!
    Sirius

    Note that the Nightly build gets updated daily (and sometimes more than once in case of a respin) and it is always possible that something goes wrong and it doesn't work properly, so be prepared for issues if you decide to stay with the Nightly build and make sure to have the current release with its own profile installed as well in case of problems.
    See also:
    * http://kb.mozillazine.org/Testing_pre-release_versions
    *http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows
    *http://kb.mozillazine.org/Shortcut_to_a_specific_profile
    *http://kb.mozillazine.org/Using_multiple_profiles_-_Firefox

  • Use of CL_BCS to send email in user exit

    Hi,
    I need some help from experts in this forum.
    I use CL_BCS to send email if a certain condition is met inside a customer exit.
    This exit is called before a confirmation dialog pop up asking whether we want to save or cancel.
    I did not put commit work statement in this exit since it will commit all database update even though the transaction can still be canceled. Email will also be sent if the transaction is save. Hence, I'm relying on commit statement that come from the transaction itself.
    However, this logic has create one problem for me.
    If user hit cancel in the confirmation dialog that pop up after the exit is called, no commit will be executed. Hence, no email will be sent.
    The problem is when the user change the data and re-save the data, there will be 2 email sent. One email come from the save action from the user and the other come from previous email that was not sent before due to no commit statement executed.
    Is there any way to prevent this to happen? Please help.
    PS: Points will be rewarded for those with helpful answer
    Message was edited by:
            Abraham Bukit

    Hi,
    May be you use commit this way.
    Create a custom function moudle , with you CL_BCS class codes and with comitt work inside and call the function in your userexit like
    call function 'Y_CL_BCS_TRIGGER'     " << Your function module name
    starting new task yscchdr-docno
    exporting
       xxxxx     = xxxxx
    aRs

  • Using MTA SDK for sending emails

    Hi,
    After taking a look to the MTA SDK documentation I still have a key question.
    My program needs to send emails to an existent SMTP server - Sun Messaging Server - running in a different box. Can I use MTA to send those emails? I read in several places "Callable Send" can be used only for sending messages from local host, so I'm not sure in my case it can be done.
    If it's possible, I'd appreciate any sample of how to do it.
    Thanks in advance,
    Jorge Ortiz Claver

    Yeah, I know I need to send the message connecting to Sun MTA but I don't know how. Actually, I know I can use a SMTP client but I'd need to use a third-party library (or build it by my own). I can't use mailx or sendmail from my application. I wouldn't have much control over its execution and each mail submit would mean a context change in my application. I need some kind of API for doing it programatically.
    My question is: what is the MTA SDK for? I know I can send/receive messages but I can't understand why I can't do it from remote. As far as I can understand, it seems like MTA SDK works directly with the same local resources Sun MTA server is using, right?
    Thanks again,
    Jorge

Maybe you are looking for

  • Flat tv mount, no room for cables

    I have a LE47le5400 led tv and ulta slim mount .  It looks great on the wall, problem is the HDMI cable dont allow the tv to sit flat on the wall, whats the solution, digging out the drywall at the exact same spot for where the cables exit the TV? Th

  • Several Idocs as single msg sent to XI

    Hello, I have a scenario where I want to receive a colection of orders05 as a single msg. in XI. That means I want to have a msg. like: <orders05> <idoc>...order 1 </idoc> <idoc>...order 2 </idoc> <idoc>...order 3 </idoc> </orders05> Normaly this can

  • Accidentally deleted trash folder

    Hello, I have searched everywhere trying to find a solution.  I had one folder on my desktop that had several subfolders inside of it.  I was deleting some desktop items and accidentally deleted this folder as well and then I emptied the trash folder

  • Making a tic tac toe grid

    hi, I've created my code and for the tic tac toe grid but I dont know how to make it look like a grid (i.e 1 2 3 4 5 6 7 8 9) it has came out as "123X56789" "X" meaning a number has taken up a cross. can anyone help?? heres the code of the grid......

  • Delay opening web pages

    I originally posted this under the Tiger section. I could not cure the problem so I purchased Snow Leopard. Problem still exists and may be worse. Problem. I use Safari and many times the system will time out before opening Safari. And once opened it