Java Mail Program - Please Help!

Hi everyone, I am new to Java (been learnig for about 6 months) and I was hoping you could help me.
I would like to write a program to be able to send and receive email (a basic version of outlook express), the prblem is that i have no idea on how to start such a program as i have only written programs such as calculators before.
I was hoping someone could tell me how to begin such a challenging program, which java package is best to create such a program, Jbuilder or the normal javac compiler.
Thanks everyone for your help

See the Java mail API for more details (javax.mail if I remember well). This can be found at:
http://java.sun.com/products/javamail/index.html
Hope it helps,
Stephane

Similar Messages

  • Deleted apple mail program, please help!

    I deleted mail, and can't seem to find it within the 'install bundled software' on the discs which came with the computer (mac os x install discs 1 & 2). How can I go about reinstalling the program? Please Help...

    Hi Rob, and a warm welcome to the forums!
    Is that the Install Disk?
    Custom installs in Mac OS X 10.4...
    http://docs.info.apple.com/article.html?artnum=301229
    "Here's a list of all the custom installation options available with Optional Installs.mpkg:
    * Applications
    o Address Book 4.0
    o iCal 2.0
    o iChat 3.0
    o iTunes 4.7.1
    o Mail 2.0
    o Oxford Dictionaries
    o Safari 2.0
    o X11"
    If that isn't the case, get Pacifist...
    http://www.charlessoft.com/
    then extract what you need from your Install Disk.

  • How to attach a word file in JAVA mail? Please help

    I am a JAVA rookie and I have problem attaching a word file using javamail. I searched almost all the forum but still couldn't find the solution.
    Sorry for the reposting. But can anybody please help me out? Your any words or links will be highly appreciated!
    Lakobe

    If you want to include an attachment with your message, you need to build up the parts, quite literally, because the name of the applicable interface is Part. The content of your Message will consist of multiple parts within a Multipart object. Part one of the message is a BodyPart that contains the message content. Part two of the message is a BodyPart that contains the attachment. The attachment itself is specified as a DataSource. You don't have to actually read the attachment.
    You start in the same way as you do for a message without an attachment. Create the message from the session and initialize the headers:
    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    message.addRecipient(Message.RecipientType.TO,
    new InternetAddress(to));
    message.setSubject("JDC Attachment");
    However here you need to create the Multipart object:
    Multipart multipart = new MimeMultipart();
    For part one, create a BodyPart and set the text to be a message. Then, add the BodyPart to the Multipart you just created.
    BodyPart messageBodyPart = new MimeBodyPart();
    messageBodyPart.setText("Here's the file");
    multipart.addBodyPart(messageBodyPart);
    For part two, you need to create a BodyPart again, but this time you need to create a DataSource for the file.
    messageBodyPart = new MimeBodyPart();
    DataSource source = new FileDataSource(filename);
    Use a DataHandler object to attach the data source to the message. Simply create a DataHandler for the source and attach it to the message:
    messageBodyPart.setDataHandler(
    new DataHandler(source));
    Remember to set the filename of the attachment. This permits the recipient to know the name (and type) of the received file.
    messageBodyPart.setFileName(filename);
    Attach part two in the same way as part one:
    multipart.addBodyPart(messageBodyPart);
    And as a final step before sending, attach the Multipart to the Message:
    message.setContent(multipart);

  • Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004 Please help me in solving this problem.

    Hello Sorry for the inconvenience, but I have a problem in Java I can not open files, audio chat, which type of jnlp after the last update of the Java 2012-004
    Please help me in solving this problem. 

    Make sure Java is enable in your browser's security settings.
    Open Java Preferences (in Utilities folder)
    Make sure Web-start applications are enabled.
    Drag Java 32-bit to the top of the list.
    jnlp isn't an audio file format. It's just a java web-start program (Java Network Launching Protocol).

  • My MacBook get's hot really quick and then discharge's quickly without opening any program, please help.

    My MacBook get's hot really quick and then discharge's quickly without opening any program, please help.
    I have checked the cooling fan, and it's working, and I took it to an IT technician and he said my hardware is allright, so is it a problem from the OS it self??
    OS X(10.8.5)

    Restart with the Option key held down and the Mac OS X install disk inserted, provide the firmware password, click on the DVD, press the button with the straight arrow, access the firmware settings, disable the password, and use FireWire Target Disk mode. If you can't do that or it doesn't work, contact Apple.
    (38384)

  • I have windows 8 and I got this error "Adobe Photoshop has stopped working" whenever I start a program. please help. how can I fix this problem? many thanks

    i have windows 8 and I got this error "Adobe Photoshop has stopped working" whenever I start a program. please help. how can I fix this problem? many thanks

    Please read these and proceed accordingly:
    http://blogs.adobe.com/crawlspace/2012/07/photoshop-basic-troubleshooting-steps-to-fix-mos t-issues.html
    http://forums.adobe.com/docs/DOC-2325

  • I just updated to Maverick and now my .mac mail account is not receiving any incoming mail.  Please help!

    I just updated to Maverick and now my .mac mail account is not receiving any incoming mail.  Please help!

    Try going to Mail/Preferences/Accounts/iCloud/Advanced and setting Authentication to Apple Token.

  • Hi I have this problem that when I send a mail to someone mails that I have already sent out end up on this email sometimes two or even twenty different mails end up going to the person I'm send ding a mail too please help

    Hi I have this problem that when I send a mail to someone mails that I have already sent out end up on this email sometimes two or even twenty different mails end up going to the person I'm send ding a mail too please help

    I have been doing some test now and have found out that my mails are being merged according to subject eg, so if I use cleaning goods as a subject and send out a new mail all mails with this subject are sent to the one person

  • HT4157 I have a cellular data account on my iPad. Almost immediately after I signed up, my e-mail was hacked and had to be cancelled. I cannot get into my AT&T cellular data account now to change the billing and account to my new e-mail. Please help.

    I have a cellular data account on my iPad. Almost immediately after I signed up, my e-mail was hacked and had to be cancelled. I cannot get into my AT&T cellular data account now to change the billing and account to my new e-mail. Please help.

    According to the AT&T Wireless web site, you can manage your iPad data plan either from the iPad, or by using a web browser:
    From the website
    Log in to your account at att.com/iPadlanding using the email address and password you used during activation.
    Your account information will display. Select the desired account change option then tap Next.
    Read the Terms of Service, and then tap Accept.
    Review the Payment Summary to ensure the details are correct. Use the Back button if changes are required, otherwise tap Submit.
    Read the Confirmation message then tap OK.

  • Problem with Java Mail Program

    Hi Everyone...
    Please help me to sort out this problem...
    I am getting this Exception while executing the code pasted below...
    javax.mail.AuthenticationFailedException
    at javax.mail.Service.connect(Service.java:306)
    at javax.mail.Service.connect(Service.java:156)
    at javax.mail.Service.connect(Service.java:105)
    at javax.mail.Transport.send0(Transport.java:168)
    at javax.mail.Transport.send(Transport.java:98)
    at JDCSend.main(JDCSend.java:38)
    It's just a simple java program to send an email using JavaMail API
    import java.io.*;
    import java.util.*;
    import javax.mail.*;
    import javax.mail.event.*;
    import javax.mail.internet.*;
    import java.util.Properties;
    public class JDCSend {
           public static void main (String args[]) {
              try{
                  String from = "[email protected]";
                  String to = "[email protected]";
                   String host = "smtp.yahoo.com";
        // Get system properties
                  Properties props = System.getProperties();
                   props.put("mail.smtp.host", host);
                   props.put("mail.smtp.port", 465);
                   props.put("mail.smtp.auth", "true");
                   props.put("mail.smtp.starttls.enable","true");
        // Get session
                  Session session = Session.getDefaultInstance(props, null);
        // Define message
                  MimeMessage message = new MimeMessage(session);
                  message.setFrom(new InternetAddress(from));
                  message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
                  message.setSubject("Hello, JDC");
                  message.setText("Welcome to the JDC");
        // Send message
                  Transport.send(message);
              catch(Exception e){ e.printStackTrace(); }
    }

    You need to be identified by stmp server :
    // Send message with authentication!
    Transport tr = session.getTransport("smtp");
    tr.connect(MailHost, user, pass);
    message.saveChanges(); // don't forget this
    tr.sendMessage(message, message.getAllRecipients());
    tr.close();
    Read JavaMail Faq please!

  • Error while running HelloWorld program Please Help me

    Hi Friends! I am doing my hello world program...while running i m getting the below error...please help me regarding this...
    The target WSCO.java cannot be started as a servlet, because the class oracle.apps.ak.ws.webui.WSCO does not extend javax.servlet.GenericServlet.
    The target WSCO.java cannot be started as an application, because the class oracle.apps.ak.ws.webui.WSCO does not have a main method.

    Hi,
    For building a simple hello world page, follow these steps:
    1) Create a New OA Workspace and a new OA Project. Make sure that package name should be prefixed by some custom name like:
    xx.oracle.apps.ak.hello
    2) Create new OA Page under webui:
    xx.oracle.apps.ak.hello.webui.XxHelloWorldPG
    3) Create a new Application module, XxHelloWorldAM in below package:
    xx.oracle.apps.ak.hello.server.XxHelloWorldAM
    4) Attach this AM to your XxHelloWorldPG.
    5) Now create regions and items under pageLayout region of this page.
    6) Add a controller to pageLayout region in webui package:
    xx.oracle.apps.ak.hello.webui.XxHelloWorldCO
    Also you can add a button on the page and write some code in PFR method of your controller.
    --Sushant                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Problem in connecting to mail store - please help me

    i have developed a mail user agent using javamail api.
    im having some problem in connecting to mail store
    it is giving MessagingException.
    the snippet is :
    store=session.getStore(url);
    try
    if(store.isConnected())
    store.close();
    store.connect();
    catch(MessagingException mexception)
    System.out.println("messaging exception store state -
    "+store.isConnected());
    //exception is raised and isConnected is false.
    --================--
    thanQ in advance
    prabhakar

    Dear tus,
    thanQ for ur suggession. i have printed stacktrace and im getting the following the exception
    please help me
    javax.mail.MessagingException: null;
    nested exception is:
    java.io.IOException
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:298)
    at javax.mail.Service.connect(Service.java:234)
    at javax.mail.Service.connect(Service.java:135)
    at javax.mail.Service.connect(Service.java:87)
    at sark.mail.MailStoreImpl.createSession(MailStoreImpl.java:356)
    at sark.mail.MailStoreImpl.fetchMails(MailStoreImpl.java:210)
    at org.apache.jsp.checkLogin$jsp._jspService(checkLogin$jsp.java:121)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet$JspServlet
    Wrapper.service(IDEJspServlet.java:174)
    at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet.serviceJsp
    File(IDEJspServlet.java:247)
    at org.netbeans.modules.tomcat.tomcat40.runtime.IDEJspServlet.service(ID
    EJspServlet.java:339)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDisp
    atcher.java:679)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationD
    ispatcher.java:431)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDis
    patcher.java:355)
    at mailController.service(mailController.java:66)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:247)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:193)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
    alve.java:243)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
    alve.java:201)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:566)
    at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve
    .java:246)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
    2344)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
    ava:164)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:566)
    at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
    rValve.java:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:564)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
    ava:170)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline
    .java:564)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:
    462)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:564)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:163)
    at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline .java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav a:472)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcesso r.java:1011)
    at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.ja va:1106)
    at java.lang.Thread.run(Thread.java:536)
    thanks in advance
    prabhakar

  • Problem compiling my first program; Please Help me!

    Please HELP, what am I doing wrong?
    For over 5hours I have been trying to figure out how to compile a simple Hello world program using sdk1.3.1_02/j2re1.3.1_02 and I am getting the following errors: helloworld.java:2 cannot resolve symbol
    symbol : class string
    location : class helloworld
    cannot reolve the string symbol
    symbol : class out
    location : package system
    I want to program in java so badly but I am trying to get my environment set so that I can take off. To compile my first program has been a disaster!!
    This is my path:
    SET PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\JDK1.3.1_02\BIN
    Thanks very much in advance
    ::(

    Java is case sensitive,
    use String instead of string. and System.out instead of system.out
    Sudha

  • Simple Java Mail program

    Hi, i have written a simple code to send mail thru java... but it doesnt work... control never comes back after stepping in to the send function.. no exceptions.. no mails sent.. nothin.. cud someone hel me out??
    sometimes i get this exception after a long time:
    javax.mail.MessagingException: Exception reading response;
    nested exception is:
         java.net.SocketException: Connection reset
         at com.sun.mail.smtp.SMTPTransport.readServerResponse(Unknown Source)
         at com.sun.mail.smtp.SMTPTransport.openServer(Unknown Source)
         at com.sun.mail.smtp.SMTPTransport.protocolConnect(Unknown Source)
         at javax.mail.Service.connect(Unknown Source)
    here is the code snippet:
    public void mySend() throws Throwable
    Properties p = System.getProperties();
    p.put("mail.transport.protocol", "smtp");
    p.put("mail.smtp.host", "smtp.gmail.com");
    p.put("mail.smtp.port", "465");
    p.put("mail.smtp.starttls.enable", "true");
    p.put("mail.smtp.auth", "true");
    Authenticator authenticator = new Authenticator()
    protected PasswordAuthentication getPasswordAuthentication()
    return new PasswordAuthentication("vicky.bhandari", "password");
    Session session = Session.getInstance(p, authenticator);
    SMTPMessage message = new SMTPMessage(session);
    InternetAddress fromAddress = new InternetAddress("[email protected]");
    InternetAddress toAddress = new InternetAddress("[email protected]");
    message.setSubject("Test");
    message.addRecipient(Message.RecipientType.TO, toAddress);
    message.setFrom(fromAddress);
    SMTPTransport.send(message);
    Could someone please help me out??

    Hey,
    Im currently having problems with the code below:
    public class SendMail {
         private static final String SMTP_HOST_NAME = "smtp.gmail.com";
         private static final String SMTP_AUTH_USER = "[email protected]";
         private static final String SMTP_AUTH_PWD = "**************";
         public void sendMail(String recipients[ ], String subject, String message , String from) throws MessagingException{
         boolean debug = false;
              Properties props = System.getProperties();
              props.put("mail.transport.protocol", "smtp");
              props.put("mail.smtp.host", SMTP_HOST_NAME);
              props.put("mail.smtp.port", "465");
              props.put("mail.smtp.starttls.enable", "true");
              props.put("mail.smtp.auth", "true");
              Authenticator auth = new SMTPAuthenticator();               
              Session session = Session.getDefaultInstance(props, auth);
              session.setDebug(debug);
              Message msg = new MimeMessage(session);
              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);
         msg.setSubject(subject);
         msg.setContent(message, "text/plain");
         Transport tr = session.getTransport("smtp");
         tr.connect(SMTP_HOST_NAME, SMTP_AUTH_USER, SMTP_AUTH_PWD);
         msg.saveChanges(); // don't forget this
         //tr.sendMessage(msg, msg.getAllRecipients());
         tr.close();
         tr.send(msg);
         public class SMTPAuthenticator extends Authenticator
         public PasswordAuthentication getPasswordAuthentication()
         String username = SMTP_AUTH_USER;
         String password = SMTP_AUTH_PWD;
         return new PasswordAuthentication(username, password);
    the error i am receiving is:
    java.lang.NoClassDefFoundError: javax/mail/Authenticator
         java.lang.Class.getDeclaredConstructors0(Native Method)
         java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
         java.lang.Class.getConstructor0(Unknown Source)
         java.lang.Class.newInstance0(Unknown Source)
         java.lang.Class.newInstance(Unknown Source)
         org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)
         org.apache.struts.action.RequestProcessor.processActionCreate(RequestProcessor.java:292)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:230)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    If anyone has any ideas it will be much appreciated
    Thanks in Advance
    Andy

  • Connecting two programs - please help

    Hi, I'm new here, so I'd like to say 'hi' to everyone :) I'm a freshman in the java comunity, so please be gentle.
    Firs of all I'd like to ask how to resolve the first problem. I've got the code which is responsible for convert a html document to the txt file. It looks like:
    import javax.swing.text.html.parser.*;
    import javax.swing.text.html.*;
    import javax.swing.text.*;
    import javax.swing.*;
    import java.io.*;
    public class TextFromHtml extends HTMLEditorKit.ParserCallback{
    static String trimmss(String o){
       return (o.trim()).replaceAll("\\s+", " ");
    public void handleText(char[] data, int pos){
    try{
          String o = new String(data);
          PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("test.txt", true)));
          o = trimmss(o);
          pw.println(o);
          //pw.close();
         catch (IOException exc){}      
    System.out.println(new String(data));
      public static void main(String args[]){
        try{
          String s = JOptionPane.showInputDialog("Enter the name of the file you want to convert from html to txt.");     
          Reader r = new FileReader(s);
          ParserDelegator parser = new ParserDelegator();
          HTMLEditorKit.ParserCallback callback = new TextFromHtml();
          parser.parse(r, callback, true); 
        catch (IOException e){
          e.printStackTrace();
         System.exit(0);
    }But unfortunately I don't know how to change this code to obtain such situation as making a new txt file without blank spaces > 0 and erasing the \n new lines. I'd like to get a txt file, which contains of line-by-line text. Could you please help me - tell & show me how to do that? I'd be very grateful
    Regards, skullscape.

    Hi Skullscape,
    My apologies for not getting a response on this forum, but this may have been because this is a fairly generic Java programming question, rather than an issue specific to the JSE product, the purpose of this particular forum.
    So may I suggest that you check out http://java.sun.com/ which has a full set of facilities for those such as yourself who are new to Java programming.
    Although by now you nay not be such a novice :-)

Maybe you are looking for

  • How can I change the AppleID in iMessage on my MacBook?

    I just downloaded the iMessage app for my MacBook and it seems to work great. Only issue is: I have 2 Apple IDs and, of course, the wrong one is now logged in. I would like to know if there is a way to change the Apple ID associated with my iMessage

  • X64 java 1.4.2_18 for SAP

    Hello Basis. I'm install yesterday new SR3 Netweaver AS JAVA (Portal+BI). On installation stage I have faced a problem.... OS are Windows x64 --> System Model:         PowerEdge 2950 System Type:           x64-based PC Processor(s):            8 Proc

  • RDS Session Broker

    Hi, actually I have an issue in an Broker scenario on Windows 2008 R2. Scenario: Windows 2008 R2 RDS 2 Session Hosts for RemoteApps and Desktop (No VD) NLB configured for the a farm on 10.1.1.100 on both Session Hosts Farmname = RDSFarm.xxxx.xxx No W

  • Uploading large documents on webcenter spaces

    Hi everybody, I want to upload large documents into webcenter spaces but documents taskflow doesn't accept documents which size are more than 2MB. (No constraint found in uploading documents directly to UCM) How can I proceed ??? Thanks for your help

  • Blur tool results seen only in palatte bin

    I am new at Photoshop. I have Elements 7, Windows 7. When working with the blur tool, I see no change to my photograph.  However I do see changes on the layer thumbnail in the palatte bin.  What am I missing?  It worked for a previous photo, but not