Can view the tutorials best in Google Chrome, Mozilla Firefox, Opera, higher version of Internet Explorer

Send Java EMail in Specific Time Interval Automatically & Dynamically

Core Java » On Oct 7, 2012 By Sivateja

Let us see how to send automatic and dynamic email using Java, this application will send email in fixed interval of time, even if you want you can change this application to send email every day at particular time :-), to wish your friends/family.

Directory Structure

GMailServer.java

DBScheduler.java

ReadPropertiesFile.java

Testing.java

Constants.java

java4s_Props.properties

Explanation

  • Run DBScheduler.java to start this application
  • First time email will sent after 2 seconds and repeats every 10 seconds until you stop your application
  • Just change .properties file and change what ever you want, you no need to touch any .java files :-)
  • You no need to touch GMailServer.java

Jars Required

  • mail.jar
  • activation.jar
  • commons-email-1.0.jar

Download these jars…..

 

Output






By [ Java/J2EE Developer & Web Designer ]
Founder of Java4s.com - Indian, lives in United States. You can contact me at sivateja@java4s.com


Comments

5 Responses to “Send Java EMail in Specific Time Interval Automatically & Dynamically”
  1. hi frnd,this is really awesome tutorial for java developers ,actuallly when iam trying to execute this example im getting error follws….

    Email Sent Succesfully…
    javax.mail.SendFailedException: Sending failed;
    nested exception is:
    class javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;
    nested exception is:
    java.net.UnknownHostException: smtp.gmail.com
    at javax.mail.Transport.send0(Transport.java:218)
    at javax.mail.Transport.send(Transport.java:80)
    at JAVAEmail.GMailServer.sendMail(GMailServer.java:61)
    at JAVAEmail.Testing.run(Testing.java:15)
    at java.util.TimerThread.mainLoop(Unknown Source)
    at java.util.TimerThread.run(Unknown Source)

    error….plz help in execution by sending an email to my mail id ,
    thanks in advance

  2. ram says:

    Hi frnd
    I also practiced wit this code its really helpful ,Thanks

  3. neha says:

    sir from where i can download BarCode128Java4s.java file….please give me the respective link..

  4. Jinshad says:

    Gud job….. Thanks a lot….

  5. Hareesh says:

    I am getting the following error plse help to slove this

    Scheduler Starterd…

    Exception in thread “Timer-0″ java.lang.NoClassDefFoundError: com/sun/mail/util/LineInputStream
    at javax.mail.Session.loadProvidersFromStream(Session.java:928)
    at javax.mail.Session.access$000(Session.java:174)
    at javax.mail.Session$1.load(Session.java:870)
    at javax.mail.Session.loadResource(Session.java:1084)
    at javax.mail.Session.loadProviders(Session.java:889)
    at javax.mail.Session.(Session.java:210)
    at javax.mail.Session.getDefaultInstance(Session.java:299)
    at emial.GMailServer.(GMailServer.java:41)
    at emial.Testing.run(Testing.java:12)
    at java.util.TimerThread.mainLoop(Timer.java:512)
    at java.util.TimerThread.run(Timer.java:462)

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Tutorials
Hibernate Recent Posts
Spring Recent Posts
Struts Recent Posts
Recomandded Links Current & UpComing Tutorials Java4s.com
Tutorials Online :
spring Hibernate struts Json Ajax Log4j Log4j
coreJava Servlets


UpComing :
JSP, Web Services [ In Progress ]
Java4s is optimized for learning java technologies, all the examples in this site are constantly reviewed to avoid errors. While using this site you agree to have read and accepted our terms of use and privacy policy
Especially i have prepared this blog by keeping fresher's in mind, however it will be very useful for real time developers too.


© 2014 Java4s All rights reserved. | strPro4Tut v(2.0) Theme designed by Team Java4s.