How can I generate auto Emails upon successful registration using jsp?

Dear all, I have been researching on how to send auto-emails using JSP for several days but I still do not understand how to do it and how it works! I tried reading JavaMail but i do not understand it can anyone help me?
Thank You very Much,

The mail.jar & activation.jar are part of Tomcat 4.x and up
Here is my simple example, you may want to make bean methods to get/properties so that you create an email like an object :-o
Notice, I make the message body a StringBuffer, so you can append info as you see fit.
Also assuming your SMTP server is the local machine, set that property to "localhost".
I also use a boolean return so I know if the message sent otherwise display a message to the user (aka, please email support to confirm your registration, etc.)
import java.util.Date;
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import java.net.InetAddress;
    private String to = "[email protected]";
    static private String from = "registered@localhost";
    private String subject = "Registered";
    private StringBuffer messageText = null;
    private Properties props = null;
    private Session sess = null;
    private InternetAddress toAddr = null;
    private InternetAddress fromAddr = null;
    public Email() {
        try{
            props = new Properties();
            props.put("mail.smtp.host","localhost");
            Session sess = Session.getDefaultInstance(props,null);
            this.toAddr = new InternetAddress(to);
            this.fromAddr = new InternetAddress(from);
            this.messageText = new StringBuffer(new Date() + "\n\n");
        } catch (Exception e) {
            e.printStackTrace();
    public boolean sendMessage(){
     try{
            // Create the message object
            Message message = new MimeMessage(sess);
            message.setFrom(fromAddr);
            message.setRecipient(Message.RecipientType.TO, toAddr);
            message.setSubject(subject);
            message.setContent(messageText.toString(),"text/plain");
            // Send Message
            Transport.send(message);
            return true;
     }catch (Exception e){
            e.printStackTrace();
            return false;
    }

Similar Messages

  • How can I send an email from Sharepoint Online using sandbox solution?

    How can I send an email from Sharepoint Online using sandbox solution?
    If possible I do not want to use workflow.
    Is It possible to do it without using workflow?

    hello Steven Andrews,
    when any user sends a message using contact us page in SharePoint online.
    1. We are inserting item in Contact Us List . - This is working fine
    for anonymous users also. We have used Office365 anonymous codeplex wsp and it is working fine. Anonymous user is able to insert new record in the Contact Us List.
    2. Once, new record is inserted in Contact Us list, we want to fire email notifying thanks to the user on his email id as well as to our company x person for notification of new inquiry. 
    We tried using Workflow having impersonation step for  anonymous user but it is not working for Anonymous users. Workflow is able to sent the email if someone logged into system but not working for Anonymous user although workflow is getting started
    but not able to send email although used Imperonsation step.
    We are stuck into implementing second step.

  • I bought a used iPhone and found him email iCloud does not affect me so how can I deleted this email in order to use the device freely and privacy

    I bought a used iPhone and found him email iCloud does not affect me so how can I deleted this email in order to use the device freely and privacy
    help me please

    You can't. Return the phone for a refund, if you can, because without the previous owner's Apple ID/Password, you will not be able to re-activate the phone. It will be useless to you.
    Apple can't/won't help you with this.

  • How can i upload files in servlets and also using jsp

    means that uploading files(.doc) or any files by using servlets and jsps

    yawmark wrote:
    saichand wrote:
    means that uploading files(.doc) or any files by using servlets and jsps
    [http://www.google.com/search?q=How+can+i+upload+files+in+servlets+and+also+using+jsp]
    ~Good topic titles are indeed brilliant search keywords. It's sad to see that it won't even come in the mind of the topicstarters to Google it before posting the topic.

  • How can we generate auto Sequence Number in DFF attribute

    Dear
    We are on r12,rignt now we have an issue to generate sequence number in site Level(DFF) on Supplier window,actully we want
    to generate sequence number on site leve while inserting new record on site level,so how could i achvie this or any way which can help us.
    --thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    You can consider writing a before-insert trigger.
    The trigger generates the next value of the sequence and makes :new.attributen = the sequence value.
    Hope this helps,
    Sandeep Gandhi

  • Please!!!!!!   How can i add rows in html table dynamically [use jsp,bean]

    hello, i am a fresher in jsp. i want to add new rows in html table dynamically.In my coding, just only shows in one row . please help my problem with correct coding and i don't want to use database. Thanks ...............!
    Here is my coding-------------------
    ---------------- form.jsp --------------------->
    <%@ page import="java.util.*,newtest1.Validation" %>
    <jsp:useBean id="mybean" scope="page" class="newtest1.Validation" />
    <jsp:setProperty name="mybean" property="name" param="name" />
    <jsp:setProperty name="mybean" property="age" param="age" />
    <% s[i][j] %>
    <html>
    <head><title>Form</title></head>
    <body>
    <form method="get">
    <table border="0" width="700">
    <tr>
    <td width="150" align="right">Name</td>
    <td width="550" align="left"><input type="text" name="name" size="35"></td>
    </tr>
    <tr>
    <td width="150" align="right">Age</td>
    <td width="550" align="left"><input type="text" name="age" size="35"></td>
    </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="5">
    <tr><td> </td></tr>
    <tr><td><input type="submit" name="submit" value="ADD"></td></tr>
    <tr><td> </td></tr>
    <tr><td width="100%" align="center" border=1>
    <% int count=mybean.getStart();
    for(int i=count; i<count+1; i++) { %>
    <tr>
    <td><jsp:getProperty name="mybean" property="name" /></td>
    <td><jsp:getProperty name="mybean" property="age" /></td>
    <td><%= count %></td>
    <% count+=1; %>
    </tr>
    <% } %></td></tr>
    </table>
    </form>
    </body>
    </html>
    ----------------- Validation.java ----------------->
    package newtest1;
    import java.util.*;
    public class Validation {
    private String name;
    private String age;
    static int start=0;
    public Validation() {    name=null;
    age=null;
    ++start;}
    public void setName(String username) { if(username!="")
    name=username;
    public String getName() { return name;  }
    public void setAge(String userage) {  if (age!="")
    {age=userage;}
    public String getAge() {  return age;   }
    public int getStart() {
    return start; }

    Hi, Do you mean to say,
    You have an HTML page in which you have a text field and an add button. If you enter anything in that text field and click on Add button the text field contents should be displayed in the same HTML page and you should be able to go on entering new values into the text field and you should be able to retain and display all the previously entered values..
    and finally the list of added items are not stored in the database..
    If this is the case
    i. Your html form should be submitted to the same page.
    ii. You need to have a Vector which holds the entered values.
    iii. Bind the vector object to the request object and collect the same vector object from the request and display its contents...
    I think this would help...

  • How can I generate email from report 6i.

    Dear Sir,
    When I click on e-mail button on report 6i (Win2k User) Generate following error:-
    Rep-4203 error occurred while a mail message.
    Rep-4220 There is a problem with the email subsystem.
    When I generate report from administrator then email generated no error occurred.
    Please help me how can I generate email from report 6i without administrator rights.
    Thanks and Regards
    Brij

    You can try this at form that calling your report;
    add_parameter(p_id,'DESFORMAT','HTML');
    hope this helps...
    defne
    ps: raporu cagiridigin form program units'ine, bu add_parameter'i eklersen, HTML olarak raporunu emailleyebilirsin...

  • How can I generate my own InDesign ePub file without the encryption.xml file?

    My bookstore (B&N) will not accept my ePub file because it doesn't want the file encryption.xml included. How can I generate an InDesign ePub file, for my own books, without it? Is there a check box somewhere? I've searched through the ePub export box and the file info boxes—no luck.
    Error message from B&N's PubIt.com:
    We have found a file name called encryption.xml within your ePub file container, which means that part of, or all of, your file is encrypted. We do not accept any encryptions within ePub source files. Upon closing this message, please remove the encryption.xml file from your ePub, and you may attempt to upload your ePub file again.
    If you wish to apply DRM to your title, go to Section 4, question H and select Yes. PubIt! will apply DRM to your title after you have uploaded your ePub file without encryption.
    Thanks for your help…

    Unfortunately you will find the option to uncheck "Embeddable Fonts" within ID CC 2014 only if you are creating an ePub with reflowable layout, but not if you are creating a "fixed layout" ePub.
    I went with the suggestion of the eCanCrusher and was pleasantly surprised how easy to use this free tool is. You basically just drag your ePub over the icon of the App and it creates a folder in which you find the encryption.xml within the META-INF folder. Once you erased it you drag the folder over the icon of the App and through this you will get a new encryption-free ePub which now passes iTunes Connect Book Proofer test.
    But then - opening the ePub without it's encryption within iBooks (on ipad) the text has moved, spaces between words are gone for no reason, words are even sticking into each other - it looks unacceptable! It does look OK on the iBook desktop app, however.
    My solution was to change the font from Myriad to Verdana. I had changed the fonts before, because - whatever font I had used - it's reproduction on the ipad was messed up, and Myriad was the first one that I tried that looked alright, though, not so much after removing the encryption.xml. Unfortunately everything changes when you change fonts within a fixed layout ePub and all line breaks have to be revised now...
    I also tried to remove the embedded fonts from inside the ePub, like someone else suggested, but that didn't help with the Book Proofer. It's really the encryption.xml that needs to be removed.
    I wish that I now finally can submit successfully to Apple and wish that Adobe would have a better relationship with Apple to solve issues like that.

  • How can i forward an email to a smart phone?

    How can i forward an email or hot link to a smart phone? Obviously the smart phone has only a numerical set so is there a way to send it to a smart phone?

    You can use a qrcode, on the computer copy the link of the site, go to this site:
    *http://qrcode.kaywa.com/
    Paste the link in the form, select static, click on generate, now save the qrcode and send by email or connect the smarth phone to your pc, transfer the qr code to the smarth phone, then use a App to read the qrcode in the smarth phone
    or type the link in a email then send to yourself, then open the email in your smarth phone, or send to somebody

  • How can I generate random password

    Hello...
    I use oracle 10g for windows,,,I have an employee table , there are a lot of colunms , their names are employee_name , employee_id ,employee_pass .....
    employee_pass colunm is empty
    I want to generate random password for employee_pass colunm
    How can I generate random password for employee_pass colunm
    thanks
    omer faruk akyuzlu
    in Turkey

    SQL>  exec dbms_random.seed(to_char(sysdate, 'sssss'))
    PL/SQL procedure successfully completed.
    SQL> select dbms_random.string('X', 8) from dual
      2  /
    DBMS_RANDOM.STRING('X',8)
    4YT1H150
    SQL> select dbms_random.string('X', 8) from dual
      2  /
    DBMS_RANDOM.STRING('X',8)
    WIA3QCIP
    SQL> Please be aware that storing the actual passwords in a the EMPLOYEES table is a very bad idea. Oracle has a pretty good password implementation. It's not perfect but it's a darn site better than hand-rolling our own.
    Cheers, APC

  • My emails do not go - they exit outbox and go to recovered. How can I delete my Icloud account and just use gmail.

    My emails go from outbox into I cloud recovered section. I have gmail too. how can I delete my icloud account and just use gmail? Speed test on wifi good.
    Any ideas please.

    Sign out of iCloud (System Preferences>iCloud)

  • How can i make a email for my printer

    how can i make a email for my printer to send the things to the email and get it printed if i was out of the house my printer model is 3525

    Hi alhashmi_sy,
    Welcome to the HP Support Forums. I see that you would like to learn how to setup the ePrint feature of your Deskjet Ink Advantage 3525 printer.
    The first step is to connect your printer to your wireless network. Please follow the steps in the Installing the Printer Software for a Wireless Network Connection document for your operating system. If you have already setup your printer with a USB cable, each operating system section has the steps to switch from the USB connection to a wireless connection.
    After connecting the printer to your wireless network please follow the steps for Getting the Printer Claim Code. Once you have the web services information sheet with your claim code please Set Up a Custom Email Address for ePrint.
    You should now have a customized ePrint email address for your printer. If you run into any issues please let me know at what step things went awry and the contents of any error messages. Please also let me know what operating system you are using on your computer (whatsmyos.com). Thank you.
    Regards,
    Happytohelp01
    Please click on the Thumbs Up on the right to say “Thanks” for helping!
    Please click “Accept as Solution ” on the post that solves your issue to help others find the solution.
    I work on behalf of HP

  • How can I Generate two different reports from single execution of Test cases in NI teststand

    Hi,
    My requirement is to generate two different reports from NI teststand. One for the Logging of error descriptions and the other report is by default generated by the Teststand. How can i generate a txt file that contains error descriptions other than that mentioned in the default report?
    Solved!
    Go to Solution.

    Do you need to do that just for these two sequences but not for other sequences? I don't see a problem to use SequenceFilePostStepRuntimeError. Create this callback in both sequence files and configure them to log into the same file. SequenceFilePostStepRuntimeError callback is called after each step of the sequence file if it has runtime error. You can access the calling step error information via RunState.Caller.Step.Result.Error property. Take a look to attached example.
    The "other way" is useful if you need to log errors not for every step of the sequence file, but for some of them. This is more complex, because you need to create a custom step types for these steps. For the custom step you can create substeps (post-step in your case) which will be executed every time after step of this type executed. Then, this is you job to determine if error happened in the step, acces to step's error information is via Step.Result.Error property. 
    Also, be aware that step's post-expression is not executed in case of error in the step.
    Sergey Kolbunov
    CLA, CTD
    Attachments:
    SequenceFilePostStepRuntimeError_Demo.seq ‏7 KB

  • How can i print an email from icloud using W 7

    How can I print an email from ICloud, from my PC, using Windows7?
    I just cannot find and icon for it. When I right click on mouse, I get print option, but it does print a blank page.
    Help please.
    Thanks,
    Rene

    Hi there Lindlylou!
    I have an article here that can explain a little more about the feature you are referencing, called AirPrint:
    AirPrint Basics
    http://support.apple.com/kb/HT4356
    That article will contain information about which printers are AirPrint compatible, as well as information about how to use AirPrint on your iPad. Thanks for using the Apple Support Communities. Have a good one!
    -Braden

  • How can I print an email from my ipad via my Lexmark printer?

    How can I print my emails from my ipad with my Lexmark printer?. I can print photos &amp; web pages.

    Hi there Lindlylou!
    I have an article here that can explain a little more about the feature you are referencing, called AirPrint:
    AirPrint Basics
    http://support.apple.com/kb/HT4356
    That article will contain information about which printers are AirPrint compatible, as well as information about how to use AirPrint on your iPad. Thanks for using the Apple Support Communities. Have a good one!
    -Braden

Maybe you are looking for

  • Display date prompt in crystal report output

    Hi There, In my report output the values entered in date prompt(range) is not displayed. I've prompt  that is created on document created on field. The properties of prompt are Posting date...... date.........static values value field : ERDAT..... va

  • MacBook Pro Retina died

    Okay, well. I have next problem: I've got my new MacBook Pro Retina with Mountain Lion 10.8.0, so of course I figured to update it to 10.8.2. In a progress of updating my MacBook just turned of, whatever it was  with 75% of battery charge. Now it's d

  • Airport Port Mapping problems...

    I have an AIRPORT EXTREME firmware 7.6.1.  I'm trying to get it to open port 443 in port mapping and it says it's open and when I port scan it's not.  Am I missing something?  Please see the enclosed image...

  • Release Stratergy User in Purchase Req.

    Hi Friends, We are using user exit to determine the Purchase Req. Approvers. In ME52N/ME53N under the Release Strategy Tab there is a table which shows the Approver name and description against each Release code. In our case we have multiple approver

  • Help with opening editor

    I can't seem to get into edit mode in any way. Any help?