Email in Java

Okay. How do you make a simple mail program. I all I need is a little sample code that when run with the email address as command line parameter send the email the exits. No gui
Any help would be hot...

So i can connect to mail.magma.ca but I can't send any mail? I'm experimenting using different types of servers and stuff, and I think i've got smtp server down. I'm trying to use ftp servers. I have some code that connects to the server but I can't submit a username or anything. It just waits.
import java.io.*;
import java.net.*;
class FTPBot {
     static Socket conect;
     static DataInputStream dis;
     static DataOutputStream dos;
     static String usr;
     static String pwd;
    static byte[] b;
     public static void main(String args[]) throws Exception {
          conect = new Socket(args[0], 21);
          dis = new DataInputStream(conect.getInputStream());
          dos = new DataOutputStream(conect.getOutputStream());
          usr = args[1];
          pwd = args[2];
          String s;
          while ((s=dis.readLine()) != null) {
           System.out.println(s);
          dos.writeBytes("user jvp02");
               while ((s=dis.readLine()) != null) {
           System.out.println(s);
          dos.writeBytes("PASS " + pwd);
               while ((s=dis.readLine()) != null) {
           System.out.println(s);
          conect.close();
}Right now i'm just trying to connect to the server and see it ackknowledge that i'm connecting and logging into an account or whatever...

Similar Messages

  • Sending Emails With Java

    I'm trying to find out how to send emails with java - without using the java mail api - i've been told there is a way to do it but i cant seem to find it - any help on this would be gratefully recieved as i'm totally stuck! :(

    Ok, I expanded on it a little bit. Still probably isnt totally correct.
    String localhost="yourdomain.com";
    String sendMailHost=�mail.domain.com�;
    int portNo=25;
    String from="[email protected]";
    String to="[email protected]";
    String message=�Message Body.�;
    Socket s = new Socket(SendMailHost,portNo);
    DataInputStream in = new DataInputStream(s.getInputStream() ) ;
    PrintStream out = new PrintStream(s.getOutputStream() ) ;
    out.println("HELO " + locahost);
    out.flush() ;
    in.readLine(); //ignore response
    out.println("MAIL FROM:  " + from);
    out.flush() ;
    in.readLine(); //ignore response
    out.println("RCPT TO:  " + to);
    out.flush() ;
    in.readLine(); //ignore response
    out.println("DATA");
    out.println(message);
    out.println(�.�);
    s.close();

  • How to create trusted emails in java

    Hey guys, I need to create trusted emails with java using 509 certifications, can anyone tell me how can i do this or perhaps give me some direction?
    Thanks on advance.

    Hi,
    what is a textbox, a JTextField? What is the datasource?
    Here are a few links to give you a better start this time:
    [Forums FAQ|http://wikis.sun.com/display/SunForums/Forums.sun.com+FAQ]
    [Getting started|http://wikis.sun.com/display/SunForums/Tips]
    And very important:
    [How to ask smart questions|http://catb.org/~esr/faqs/smart-questions.html]

  • How to send emails using java code

    Hi,
    can any give me some sample code for sending emails using java language

    JavaMail quick start
    jGuru: Fundamentals of the JavaMail API

  • Emailing in java

    I do not now how I can send and email using java. Could you help me??

    You should search for forums for this topic...there have been a lot of similar questions.
    note: there is a search tool in this forum right under where you sign in.
    Ny

  • Sending Email using java code

    I am using the following code to send an email from my java servlet but the problem is, when it is on its own it works fine but as soon as I combine it with some code to submit data into a postgres database it sometimes does not perform could it be because im missing some close statements??
    //grades to submit grades starts here
                                                           String [] paramValues = req.getParameterValues("Mark");
                                                      for(int i=0; i<paramValues.length;i++)
                                                           String [] paramValues2 = req.getParameterValues("StudentExamNumber");
                                                                String Mark = paramValues;
                                                                String ExamNo = paramValues2[i];
                                                                //testing purposes
                                                                out.println("<tr><td>"+ExamNo+"</td>");
                                                                out.println("<td>"+Mark+"</td>");
                                                                try
                                                           st = conn.createStatement();
                                                           query = "SELECT StudentNo FROM STUDENTS"+WebCourse2+ " where ExamNo='"+ExamNo+"'";
                                                           rs = st.executeQuery(query);
                                                           if(rs !=null)
                                                                          while(rs.next())
                                                                               String StudentNo=rs.getString("StudentNo");
                                                                               //testing purposes
                                                                               //out.println("<td>"+StudentNo+"</td></tr>");
                                                                               here
                                                                               st4 = conn.createStatement();
                                                                     query4 = "select MAX(entryno) from STUDENTRESULTSFORCOURSE"+WebCourse2+" WHERE STUDENTNO='"+StudentNo+"'";
                                                                     rs4 = st4.executeQuery(query4);
                                                                     if(rs4 !=null)
                                                                                    while(rs4.next())
                                                                                         EntryNo = rs4.getInt(1);
                                                                                    }//end rs4 while
                                                                                    rs4.close();
                                                                               }//end rs4 if
                                                                     out.println("<tr><td>EntryNo= "+EntryNo+"</td>");
                                                                               EntryNo = EntryNo + 1;
                                                                               out.println("<td>NewEntryNo= "+EntryNo+"</td></tr>");
                                                                               //Submitting grades to database/
                                                                     st3 = conn.createStatement();
                                                                     insert = "insert into STUDENTRESULTSFORCOURSE"+WebCourse2+" (StudentNo, CourseCode, AttemptNo, ExamMark, EntryNo, EnteredBy) values ('"+StudentNo+"', '"+WebCourse2+"', 1,'"+Mark+"',"+EntryNo+",'"+WebUsername2+"')";
                                                                     st3.executeUpdate(insert);
                                                                          }//end rs while
                                                                          rs.close();
                                                                     }//end rs if
                                                                }//end try
                                                                catch (SQLException e)
                                                                     System.out.println("Error: "+e.getMessage());
                                                           }//end for loop     
                                                           //code to submit grades ends here
                                                           //code used to send email starts here
                                                           String m_sHostName="localhost";
                                                      int m_iPort=25;
                                                           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.
                                                                     System.out.println("Connection was made. Socket is ready for use.");
                                                                     try
                                                                          // The email address that the server
                                                                          // you are using know user as.
                                                                          os.writeBytes("MAIL From: <[email protected]>\r\n");
                                                                          // Who the email is going to.
                                                                          os.writeBytes("RCPT To: <[email protected]>\r\n");
                                                                          //send a CC to:
                                                                          os.writeBytes("RCPT Cc: <[email protected]>\r\n");
                                                                          // 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("From: "+WebUsername2+"<[email protected]>\r\n");
                                                                          os.writeBytes("To: Marie <[email protected]>\r\n");
                                                                          //Again if you want to send a CC then add this.
                                                                          os.writeBytes("Cc: ProfCuthbert <[email protected]>\r\n");
                                                                          String sMessage = "ELECTRONIC ENGINEERING EXAM COLLATION SYSTEM EMAIL\n\nThe results for the following course have been submitted by the following member of staff\n\nCOURSE: "+WebCourse2+"\n\nSUBMITTED BY: "+WebUsername2+" \n\nPLEASE LOCK COURSE NOW IN ORDER TO PREVENT ANY FURTHER SUBMISSIONS TO BE MADE BY USERS.";
                                                                          os.writeBytes("Subject: A SUBMISSION HAS BEEN MADE FOR COURSE "+WebCourse2+"\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.
                                                                          // Once an OK is reached you are complete.
                                                                          String responseline;
                                                                          //for testing purposes
                                                                          //out.println(responseline = is.readLine());
                                                                          while((responseline = is.readLine())!=null)
                                                                          //for testing purposes
                                                                          //out.println("responseline= "+responseline+"<br>");
                                                                          //out.println("responseline.indexOf(Ok)= "+responseline.indexOf("Ok"));
                                                                          if(responseline.indexOf("Ok") != -1)
                                                                          break;
                                                                          if(responseline.indexOf("Ok") == -1)
                                                                          confirm=1;
                                                                          if (confirm==1)
                                                                          out.println("<br>the marks have been submitted thank you");
                                                                          catch(Exception e)
                                                                          {  System.out.println("Cannot send email as an error occurred.");
                                                                               out.println("Cannot send email as an error occurred.");
                                                           catch(Exception e)
                                                           { System.out.println("Host " + m_sHostName + "unknown"); }
    Does anyone know what the problem is??
    thanks
    tzaf

    i close them later in the program. Ive made sure they are all closed I have a feeling that it could be coming from here....
    //code used to send email starts here
                                                           String m_sHostName="localhost";
                                                      int m_iPort=25;
                                                           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.
                                                                     System.out.println("Connection was made. Socket is ready for use.");
                                                                     try
                                                                          // The email address that the server
                                                                          // you are using know user as.
                                                                          os.writeBytes("MAIL From: <email address>\r\n");
                                                                          // Who the email is going to.
                                                                          os.writeBytes("RCPT To: <email address>\r\n");
                                                                          //send a CC to:
                                                                          os.writeBytes("RCPT Cc: <email address>\r\n");
                                                                          // 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("From: "+WebUsername2+"<email address>\r\n");
                                                                          os.writeBytes("To: hello<email address>\r\n");
                                                                          //Again if you want to send a CC then add this.
                                                                          os.writeBytes("Cc: hello <email address>\r\n");
                                                                          String sMessage = "ELECTRONIC ENGINEERING EXAM COLLATION SYSTEM EMAIL\n\nThe results for the following course have been submitted by the following member of staff\n\nCOURSE: "+WebCourse2+"\n\nSUBMITTED BY: "+WebUsername2+" \n\nPLEASE LOCK COURSE NOW IN ORDER TO PREVENT ANY FURTHER SUBMISSIONS TO BE MADE BY USERS.";
                                                                          os.writeBytes("Subject: A SUBMISSION HAS BEEN MADE FOR COURSE "+WebCourse2+"\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.
                                                                          // Once an OK is reached you are complete.
                                                                          String responseline;
                                                                          //for testing purposes
                                                                          //out.println(responseline = is.readLine());
                                                                          while((responseline = is.readLine())!=null)
                                                                          //for testing purposes
                                                                          //out.println("responseline= "+responseline+"<br>");
                                                                          //out.println("responseline.indexOf(Ok)= "+responseline.indexOf("Ok"));
                                                                          if(responseline.indexOf("Ok") != -1)
                                                                          break;
                                                                          if(responseline.indexOf("Ok") == -1)
                                                                          confirm=1;
                                                                          if (confirm==1)
                                                                          out.println("<br>the marks have been submitted thank you");
                                                                          catch(Exception e)
                                                                          {  System.out.println("Cannot send email as an error occurred.");
                                                                               out.println("Cannot send email as an error occurred.");
                                                           catch(Exception e)
                                                           { System.out.println("Host " + m_sHostName + "unknown"); }
                                                           //code used to send email ends here
    do i need to close is and os?
    thanks
    tzaf

  • Sending email using java

    Im using this code to do this, but i have a feeling that I need to close os and is is that the case? do i need to close anything else?
    thanks
    tzaf
    //code used to send email starts here
                                                           String m_sHostName="localhost";
                                                      int m_iPort=25;
                                                           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.
                                                                     System.out.println("Connection was made. Socket is ready for use.");
                                                                     try
                                                                          // The email address that the server
                                                                          // you are using know user as.
                                                                          os.writeBytes("MAIL From: <[email protected]>\r\n");
                                                                          // Who the email is going to.
                                                                          os.writeBytes("RCPT To: <[email protected]>\r\n");
                                                                          //send a CC to:
                                                                          os.writeBytes("RCPT Cc: <[email protected]>\r\n");
                                                                          // 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("From: "+WebUsername2+"<[email protected]>\r\n");
                                                                          os.writeBytes("To: Marie <[email protected]>\r\n");
                                                                          //Again if you want to send a CC then add this.
                                                                          os.writeBytes("Cc: ProfCuthbert <[email protected]>\r\n");
                                                                          String sMessage = "ELECTRONIC ENGINEERING EXAM COLLATION SYSTEM EMAIL\n\nThe results for the following course have been submitted by the following member of staff\n\nCOURSE: "+WebCourse2+"\n\nSUBMITTED BY: "+WebUsername2+" \n\nPLEASE LOCK COURSE NOW IN ORDER TO PREVENT ANY FURTHER SUBMISSIONS TO BE MADE BY USERS.";
                                                                          os.writeBytes("Subject: A SUBMISSION HAS BEEN MADE FOR COURSE "+WebCourse2+"\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.
                                                                          // Once an OK is reached you are complete.
                                                                          String responseline;
                                                                          //for testing purposes
                                                                          //out.println(responseline = is.readLine());
                                                                          while((responseline = is.readLine())!=null)
                                                                          //for testing purposes
                                                                          //out.println("responseline= "+responseline+"<br>");
                                                                          //out.println("responseline.indexOf(Ok)= "+responseline.indexOf("Ok"));
                                                                          if(responseline.indexOf("Ok") != -1)
                                                                          break;
                                                                          if(responseline.indexOf("Ok") == -1)
                                                                          confirm=1;
                                                                          if (confirm==1)
                                                                          out.println("<br>the marks have been submitted thank you");
                                                                          catch(Exception e)
                                                                          {  System.out.println("Cannot send email as an error occurred.");
                                                                               out.println("Cannot send email as an error occurred.");
                                                           catch(Exception e)
                                                           { System.out.println("Host " + m_sHostName + "unknown"); }
                                                           //code used to send email ends here

    any thoughts?
    thanks
    tzaf

  • Error while sending Email through Java Code in OIM

    Hi All,
    I have created a java code using tcEmailNotificationUtil, and integrated the same with the adapter.
    I am triggering this adapter when an approval process gets completed.
    As soon as the approval process gets completed my email task is triggering but the task is getting rejected.
    I have checked my system configuration for mail server settings.Everything seems working fine.
    Can you please help me in this issue how to debug?
    Thanks in advance.

    Hi,
    Here is my log file:
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/insertTaskHistory left.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/run entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/execute entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/initialize entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/getAttribute entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/getAttribute left.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/getUtility entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/getUtility left.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.ACCOUNTMANAGEMENT] - Class/Method: tcUtilityFactory/getRemoteUtility - Data: moUtil - Value: Thor.API.Operations.tcAuditOperationsClient
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/initialize left.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/processAllByIdentifier entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped left.
    DEBUG,25 Apr 2011 10:40:00,100,[XELLERATE.DATABASE] - select A.* from (select aud_jms_key, aud_class, identifier from aud_jms order by aud_jms_key) A where rownum <= ?
    INFO,25 Apr 2011 10:40:00,101,[XELLERATE.PERFORMANCE] - Query: DB: 1, LOAD: 0, TOTAL: 1
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped entered.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped entered.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/execute left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/run left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isSuccess entered.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isSuccess left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SERVER] - Class/Method: SchedulerTaskLocater /removeLocalTask entered.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SERVER] - Class/Method: SchedulerTaskLocater /removeLocalTask left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/updateStatusToInactive entered.
    DEBUG,25 Apr 2011 10:40:00,104,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/updateStatusToInactive left.
    DEBUG,25 Apr 2011 10:40:00,104,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/updateTaskHistory entered.
    DEBUG,25 Apr 2011 10:40:00,106,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/updateTaskHistory left.
    DEBUG,25 Apr 2011 10:40:00,106,[XELLERATE.SERVER] - Clearing Security Associations with thread executing Scheduled task
    DEBUG,25 Apr 2011 10:40:00,106,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/run left.
    DEBUG,25 Apr 2011 10:40:00,106,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/execute left.
    and I just wanted to ensure that my coding part is also fine.
    Posting the code even:
    tcDataProvider ioDatabase = new tcDataBaseClient();
    tcEmailNotificationUtil sendMail = new tcEmailNotificationUtil(ioDatabase);
    sendMail.setBody("Sample Message");
    sendMail.setSubject("subject");
    sendMail.setFromAddress("fromemailaddress");
    sendMail.sendEmail("recepient");
    Thanks in Advance.

  • Problem: Error while sending Email.(Java Mail API)

    Hi to ALL
    I am trying to build Application to send Email
    Below code is primary code to send Email to other smtp host.
    & also debug information is as shown below.
    If possible, then please send the solution.
    -------------------------------Code :-----------------------------------------
    URLName urlN=new URLName("smtps://"+userNm+":"+passwd+"@"+host);
    Properties props = System.getProperties();
    Session session = Session.getDefaultInstance(props);
    session.setDebug(true);
    Message msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(from));
    InternetAddress[] address= InternetAddress.parse(to, false);
    msg.setRecipients(MimeMessage.RecipientType.TO, address);
    msg.setSubject("subject");
    msg.setContent("messageSend Hi", "text/plain");
    Transport transport=session.getTransport(urlN);
    transport.connect();
    transport.sendMessage(msg, address);
    ---------- Java Run ----------
    DEBUG: setDebug: JavaMail version 1.3.2
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG SMTP: trying to connect to host "hostName", port 465, isSSL true
    220 smtp110.mail.mud.yahoo.com ESMTP
    DEBUG SMTP: connected to host "hostName", port: 465
    EHLO patil
    250-smtp110.mail.mud.yahoo.com
    250-AUTH LOGIN PLAIN XYMCOOKIE
    250-PIPELINING
    250 8BITMIME
    DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XYMCOOKIE"
    DEBUG SMTP: Found extension "PIPELINING", arg ""
    DEBUG SMTP: Found extension "8BITMIME", arg ""
    DEBUG SMTP: use8bit false
    MAIL FROM:<from email address>
    530 authentication required - for help go to http://help.yahoo.com/help/us/mail/pop/pop-11.html
    com.sun.mail.smtp.SMTPSendFailedException: 530 authentication required - for help go to http://help.yahoo.com/help/us/mail/pop/pop-11.html
    at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1275)
    at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:895)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:524)
    at SendEmail2.<init>(SendEmail2.java:46)
    at SendEmail2.main(SendEmail2.java:23)
    Exception : com.sun.mail.smtp.SMTPSendFailedException: 530 authentication required - for help go to
    http://help.yahoo.com/help/us/mail/pop/pop-11.htmls
    -------------------------------------------------------------------------------------

    It's possible. It's only software, after all.
    But it's not easy. It effectively involves
    screen scraping the HTML pages.
    There used to be a third party JavaMail provider
    that did all the hard work, but it has disappeared.

  • Problem in retrieving email using java mail api

    hi,
    In my project,i am retrieving mails from a particular email id.
    I am able to retrieve the latest mails and save it in a folder in my system.
    The problem is whenever i run the program eventhough the most recently received mail in inbox is retrieved and saved,again it is retrieving the same one and saving it in the same folder(not repeating).
    I tried to check the newmessages in the inbox using the folder.hasNewMessage() method in java mail api,but the method is returning false only regardless new mail is there in inbox or not.
    I want to read the unread messages only.Dont want to retrieve the already read mails.
    I got the mail retrieving code from the below site.(sorry not posting the code because it is so long and having 4 classes)
    http://www.builderau.com.au/program/java/soa/Getting_the_mail_in_receiving_in_JavaMail/0,39024620,39228060,00.htm
    Can anyone tell me how to read unread mails in the inbox?
    Thanks a lot

    hi parvathi
    i think your mail program is receving mails using imap
    the imap is only receve the mail from server but the pop is deleting the mails after receving
    use the following sample code
    package com.sfrc.mail.pop;
    import javax.mail.*;
    import javax.mail.internet.*;
    import com.sun.mail.handlers.message_rfc822;
    import java.util.*;
    import java.io.*;
    * Owner: SFRC IT Solutions Pvt Ltd
    * Author:Arunkumar Subramaniam
    * Date :12-06-2006
    * File Name: AttachRecive.java
    public class AttachRecive
    public static void main(String args[])
    try
    String popServer="192.168.1.1";
    String popUser="pl";
    String popPassword="password";
    // Create empty properties
    Properties props = new Properties();
    // Get session
    Session session = Session.getDefaultInstance(props, null);
    // Get the store
    Store store = session.getStore("pop3");
    store.connect(popServer, popUser, popPassword);
    // Get folder
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_ONLY);
    // Get directory
    Message message =folder.getMessages();
    Multipart mp = (Multipart)message.getContent();
    for (int i=0, n=mp.getCount(); i<n; i++) {
    Part part = mp.getBodyPart(i);
    String disposition = part.getDisposition();
    // Close connection
    folder.close(false);
    store.close();
    catch (Exception ex)
    System.out.println("Usage: "
    +" popServer popUser popPassword");
    System.exit(0);
    Regards
    Arunkumar Subramaniam
    SFRC IT Solutions Pvt Ltd
    Chennai

  • I am not able to send email using JAVA API to outer email

    If I am trying to send email from my company account to yahoo I am getting following errors:
    javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
    for [email protected]
    at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1196)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)
    at javax.mail.Transport.send0(Transport.java:169)
    at javax.mail.Transport.send(Transport.java:98)
    at MailSend.main(MailSend.java:116)
    Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to rel
    ay for [email protected]
    at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1047)
    ... 4 more
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for mkba
    [email protected]
    at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1047)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)
    at javax.mail.Transport.send0(Transport.java:169)
    at javax.mail.Transport.send(Transport.java:98)
    at MailSend.main(MailSend.java:116)
    Please let me know the reason for the same.

    Unable to relay - This happened because your Company network don't permit relay. Do talk to the network administrator and check with way safe you can send.
    I got the same problem, now im using through gmail.

  • When I try to remote access to my VPN email a java preference box opens and will not do anything more.

    I have always been able to remote access to my office email through VPN access. Now when I try to, a Java preference box pops up and there seems to be no way to get past it. Before, java would just load. Now it won't. I had my operating system upgraded and Java reinstalled but this did not solve the problem.
    Any ideas?

    Please post a screenshot.

  • Attachment to email from java

    Hi.
    This is the code I use to get the default client and to create an email:
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler mailto:[email protected]?subject=Invio%20file%20JDocException.txt&body=see%20attachment&attachment=fileName");   Everything goes fine but the attachment. Is there something wrong??
    Thanks

    You could use
    JDIC's Desktop.mail( ... )
    Message.setAttachments(java.util.List).

  • Can I send email using Java from my localhost(Tomcat) with Internet connect

    Hi friends,
    Please tell me can I send email from my localhost (Tomcat) using Java when my computer is connected to Internet?
    I don't have any SMTP username or password or the like, as I found in some codes available in net.
    Please suggest and any simple code if possible.
    Please don't send me the link of JavaMail API to read.
    ---Sujoy

    Thank you for the link. Though I have not tested the provided code, I will test it.
    --Sujoy                                                                                                                                                                                       

  • Need help on emailing  from java

    I need help on how to send an Email from a java application.
    Can any body help me by providing correct code for that?
    Thanks!

    It worked.Thanks!So, are you gonna award the Dukes to prometheuzz or are you donating them to the forum pickle jar?
    db

Maybe you are looking for

  • Urgent help need on swing problem

    Dear friends, I met a problem and need urgent help from guru here, I am Swing newbie, I have following code and hope to draw lines between any two components at RUN-TIME, not at design time Please throw some skeleton code, Thanks so much!! code: pack

  • Links/material are specific to Ticket/Incident management aspect of SOLMAN

    Hi All SOLMAN Experts, I have been recently assigned to a project which has lot of work in Ticket/Incident Management through SOLMAN. I have never used SOLMAN. Can you guys guide me on links or material releated to SOLMAN and it will really help if t

  • How can I get rid of numbers that are covering my entire desktop, caused by right-clicking "Clean Up Selection" on an icon?

    How can I get rid of numbers that are covering my entire desktop, caused by right-clicking "Clean Up Selection" on an icon?  The Apple OS X Mavericks blue & green desktop is totally gone.  HELP!

  • MAP  not updating

    dear friends i Have a peculiar problem in my company , only for materials which are one in quantity , if after 601 we are doing sales return 653 then materials which were in one quantity there MAP becomes zero and in 653 movement in mb5b there map is

  • PRINTING 2-up

    Could someone please let me know how to make a file 2-up on a letter sized paper (portrait) The file is in Indesign and it's 8 x 5.5 (A notecard) I want to print it 2-up complete with crop marks, especially marks to show where to cut right in the mid