Trying to import javax.mail.*

hi,
I need to make a sort of webmail program for school, i understand most of the things I've read so far about it but when i actually try to program and import javax.mail.* and javax.mail.internet.* Together (the compiler we have to use) doesn't recognise these import
any help would be appreciated because i'm dying to get started :)

Hi,
You need to have java mail jar files in your classpath.
They are available for download at http://java.sun.com/products/javamail/downloads/index.html
-Amol

Similar Messages

  • Problem importing javax.mail.*

    Hey,
    I just installed the Java JDK 6 update 16 (windows platform). I am not able to compile a sample code that used the javax.mail package. I am not able to get past the
    import javax.mail.*;
    line. The compiles says "package javax.mail does not exist"
    I tried separately installing the JavaMail 1.4.2 API and setting the classpath to the mail.jar file as suggested in the readme.txt for this API, but I still get the same problem. Anyone has any suggestions?
    Thanks!

    Hi! I see you've answered similar problems before - but nothing seems to be working for me.
    My OS is Vista. I installed the JDK 6 update 16 just yesterday. I'm using the command line javac.
    I can see the mail.jar file in this folder: C:\Sun\SDK\lib\ and I've set the classpath using : set classpath=%classpath%;C:\Sun\SDK\lib\mail.jar
    When I type set classpath at the prompt, I can see that the classpath has been set correctly.
    Please help!

  • Import javax.mail.* problem ...

    I have added the line 'import javax.mail.*;' to the top of my program and got the compiler error 'Package javax.mail not found in import'. I have since read through loads of similar problems on this forum and have tried the following :-
    Downloaded jaf-1_0_2.zip and javamail-1_3.zip from the Sun site, unzipped them, and placed mail.jar and activation.jar onto my PC. I have added these .jar files into my classpath and re-booted my PC. However, I STILL get the same compiler message and it's doing my head in! Do I somehow need to add the .jar files into my project? Or am I just being very thick? I am developing using Visual Cafe 3.0. I am using JDK 1.2.2.
    I am quite new to this and I have not even started to code the e-mailing method yet - I'm simply trying to get the import working.
    Any help would be much appreciated and would mean I can sleep tonight!
    Thanks in advance.

    Hi,
    check where you have placed the mail.jar file.....give the proper classpath where you have placed the jar file....
    check this out....it will compile...

  • Import javax.mail package does not exists

    Hi,
    when i tried to compile the source code for email using jdk1.3.1, it compiled fine. but when i tried to compile using jdk1.4.., it had the following errors such as
    import javax.mail package does not exists,
    import javax.mail.internet package does not exists
    package javax.activation does not exist
    Is it because of the jdk version problem???
    Pls help me

    I have the same problem with javax.ejb
    Now i've downloaded and installed the j2ee and set my classpath to the j2ee.jar. I've had to make a new path cause i'm running XP.
    This doesn't work.
    to compile it in Jcreator or JBuilder I can make it work by adding this package (j2ee.jar) in the project settings - required libraries.
    But I have to do this for every project again and again.
    I can make it work but i thougt the classpath would be enough ??
    Bassegio

  • Import javax.mail not found problem

    I have downloaded the most recent mail.jar and activation.jar files and have created a library w/in JDev called javamail and have added these jars to that library. I have also included this library in my ViewController Project. The problem I am having is that the following imports statements are not found by JDev:
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.Multipart;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeBodyPart;
    import javax.mail.internet.MimeMessage;
    import javax.mail.internet.MimeMultipart;
    When I open up the mail.jar I can find all of these classes, so why are these imports not being recongnized?
    I have also tried import javax.mail.*; to include everthing and this does not work either.
    Does anyone have any suggestions on how to trouble shoot this issue?

    Try to add the J2EE library - which is predefined in JDeveloper- to your project's libraries.
    Worked for me.

  • Import javax.mail not found

    Hello,
    I am new to Java Mail. I wanted to test my first programme. When I compile, I get this errors.
    package javax.mail not found in import and so on. I have set my classpath to so
    set classpath = %classpath%;C:\j2sdk1.4.0\lib\mail.jar;C:\j2sdk1.4.0\lib\activation.jar
    I included the mail.jar,smtp.jar and activation.jar in the lib directory of my jdk e.g c:\j2sdk1.4.0\lib\ "the jar file".
    Can any one tell me what I am missing here?
    Thanks
    James

    the easiest way to do this is to put
    activation.jar
    mail.jar          
    mailapi.jar     
    imap.jar     
    smtp.jar          
    pop3.jar
    into the virtual machine directory C:\Program Files\JavaSoft\JRE\1.3.1\lib\ext
    or the lib\ext directory of whatever virtual machine you are using
    and put coppies of them in JDK
    C:\j2sdk1.4.0-beta3\jre\lib\ext
    or jre\lib\ext
    of whatever JDK you are using
    this way they are found automaticaly
    no need for classpath

  • Trying to import Windows Mail into Thunderbird.

    FAQ says to use Tools|Import/export|Import all messages from a directory. All I get is Import and nothing else. No Import/Export etc. When I proceed, only options are form Eudora, Outlook and Outlook Express and no Windows Mail. Picked OE but doesn't work. I exported WinMail .eml files to a new directory for selection.

    https://support.mozilla.org/en-US/questions/1031812

  • ADF Mobile Client : Error while trying to import javax.microedition.*

    Hi,
    JDev throws errors at compile time when I try to deploy a sample ADF Mobile Client application.
    These errors are related to javax.microedition.io.* imports.
    Error(11,29): package javax.microedition.io does not exist
    Error(12,29): package javax.microedition.io does not exist
    Error(180,9): cannot find class HttpConnection
    Error(191,27): cannot find class HttpConnection
    Error(191,42): cannot find variable Connector
    Error(250,49): inconvertible types
    Error(303,40): cannot find variable HttpConnection
    Any pointers as to how these errors could be resolved?
    Is there a JDev Wireless extension that should be installed to resolve these J2ME related errors?
    For JDev 10g, I could locate one such extension called JWE here : http://www.oracle.com/technology/products/iaswe/archive/developer/index.html
    I could not find any similar extension for JDeveloper 11.1.3.
    Regards,
    Prasad.

    Hi, just want to make sure - did you install the ADF MObile Client extension yet? Please go to JDev-Help-Check for Updates-Official Oracle Extensions and Updates, and find Oracle ADF MObile Client Extension in the list. Check it, download it, and then restart JDev. Sounds like the extension was not installed, so it's not able to load any J2ME libraries.
    If you have downloaded the extension already, please go to project properties-libraries and classpath, and then see if the sample app is referencing some third party libraries, for example something from RIM. If so, please double check the path to the library.
    Once you installed the extension, you can also access the ADF Mobile Client developer guide - it contains all the documentation around what you need to install first. Please take a look and see what you need to install - at a minimum, you need to install BlackBerry JDE if you want to deploy to BlackBerry, and Windows Mobile Emulator if you want to test the app on Windows Mobile. Lastly, if you need to synchronize data, then you also need Oracle Database Lite MObile Server installation.
    Thanks,
    Joe Huang

  • Trying javax.mail

    Im trying to getsome code to work for me that sends mail via the javax.mail protocol or api sorry.....anywho i get the mail to send and everything is great will somebody tell me if javax.mail has a simple attachment feature in it i need to attach a file now that it is sending........ maybe i could send my code to send it and someone can walk me through attaching a file before sending it.....im very new at this so

    Hi, you can try something like this:
    import java.util.*;
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    *    @author  Christopher Cotton
    public class sendfile {
        public static void main(String[] args) {
      if (args.length != 5) {
          System.out.println("usage: java sendfile <to> <from> <smtp> <file> true|false");
          System.exit(1);
      String to = args[0];
      String from = args[1];
      String host = args[2];
      String filename = args[3];
      boolean debug = Boolean.valueOf(args[4]).booleanValue();
      String msgText1 = "Sending a file.\n";
      String subject = "Sending a file";
      // create some properties and get the default Session
      Properties props = System.getProperties();
      props.put("mail.smtp.host", host);
      Session session = Session.getInstance(props, null);
      session.setDebug(debug);
      try {
          // create a message
          MimeMessage msg = new MimeMessage(session);
          msg.setFrom(new InternetAddress(from));
          InternetAddress[] address = {new InternetAddress(to)};
          msg.setRecipients(Message.RecipientType.TO, address);
          msg.setSubject(subject);
          // create and fill the first message part
          MimeBodyPart mbp1 = new MimeBodyPart();
          mbp1.setText(msgText1);
          // create the second message part
          MimeBodyPart mbp2 = new MimeBodyPart();
                // attach the file to the message
            FileDataSource fds = new FileDataSource(filename);
          mbp2.setDataHandler(new DataHandler(fds));
          mbp2.setFileName(fds.getName());
          // create the Multipart and add its parts to it
          Multipart mp = new MimeMultipart();
          mp.addBodyPart(mbp1);
          mp.addBodyPart(mbp2);
          // add the Multipart to the message
          msg.setContent(mp);
          // set the Date: header
          msg.setSentDate(new Date());
          // send the message
          Transport.send(msg);
      } catch (MessagingException mex) {
          mex.printStackTrace();
          Exception ex = null;
          if ((ex = mex.getNextException()) != null) {
        ex.printStackTrace();
    }

  • Import statement not found for javax.mail.Message

    when i'm in webSphere shich is using jdk1.4.2,
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.Session;
    import javax.mail.internet.AddressException;
    import javax.mail.internet.InternetAddress;
    cannot be found
    Where would the Mail classes be located?
    Thank you

    mail.jar and activation.jar, which can be downloaded here:
    http://java.sun.com/products/javamail/downloads/index.html
    http://java.sun.com/products/javabeans/jaf/downloads/index.html

  • Import from javax.mail cannot be resolved

    Hi,
    After migration from Netweaver 7.0 to 7.1 CE, the import of the package  import javax.mail.*
    The error is javax.mail cannot be resolved.
    Do I have to add special Dependencies to my DC?
    Best regards,
    Peter

    Hi
    Please refer following thread.
    [external jar in CE|import a external jar in web dynpro project;
    [external library insight webdynpro |Problem in Reading Excel File from Webdynpro;
    Best Regards
    Satish Kumar

  • Package javax.mail does not exist (Still having trouble)

    Good Morning
    I know that there are several posts regarding issues with javamail. I have viewed them for the past hour. While several of them address my issue I have been unable to locate a solution.
    Bare with me please, I am making this post very thorough. The other threads I have read are frusterating because the problems people tend to post are not clear.
    I am trying to run "msgsend" which is a provided demo of javamail-1.4 using command prompt (start - run - cmd) with the javac command.
    The output below is directly pasted from command prompt and written in bold.
    C:\download\javamail-1.4\demo>javac msgsend.java
    C:\download\javamail-1.4\demo>javac msgsend.java
    msgsend.java:44: package javax.mail does not exist
    import javax.mail.*;
    ^
    msgsend.java:45: package javax.mail.internet does not exist
    import javax.mail.internet.*;
    ^
    msgsend.java:140: cannot find symbol
    symbol : class Session
    location: class msgsend
    Session session = Session.getInstance(props, null);
    ^
    msgsend.java:140: cannot find symbol
    symbol : variable Session
    location: class msgsend
    Session session = Session.getInstance(props, null);
    ^
    msgsend.java:145: cannot find symbol
    symbol : class Message
    location: class msgsend
    Message msg = new MimeMessage(session);
    ^
    msgsend.java:145: cannot find symbol
    symbol : class MimeMessage
    location: class msgsend
    Message msg = new MimeMessage(session);
    ^
    msgsend.java:147: cannot find symbol
    symbol : class InternetAddress
    location: class msgsend
    msg.setFrom(new InternetAddress(from));
    ^
    msgsend.java:151: package Message does not exist
    msg.setRecipients(Message.RecipientType.TO,
    ^
    msgsend.java:152: cannot find symbol
    symbol : variable InternetAddress
    location: class msgsend
    InternetAddress.parse(to,
    ^
    msgsend.java:154: package Message does not exist
    msg.setRecipients(Message.RecipientType.CC,
    ^
    msgsend.java:155: cannot find symbol
    symbol : variable InternetAddress
    location: class msgsend
    InternetAddress.parse(cc,
    ^
    msgsend.java:157: package Message does not exist
    msg.setRecipients(Message.RecipientType.BCC,
    ^
    msgsend.java:158: cannot find symbol
    symbol : variable InternetAddress
    location: class msgsend
    InternetAddress.parse(bcc,
    ^
    msgsend.java:167: cannot find symbol
    symbol : class MimeBodyPart
    location: class msgsend
    MimeBodyPart mbp1 = new MimeBodyPart();
    ^
    msgsend.java:167: cannot find symbol
    symbol : class MimeBodyPart
    location: class msgsend
    MimeBodyPart mbp1 = new MimeBodyPart();
    ^
    msgsend.java:169: cannot find symbol
    symbol : class MimeBodyPart
    location: class msgsend
    MimeBodyPart mbp2 = new MimeBodyPart();
    ^
    msgsend.java:169: cannot find symbol
    symbol : class MimeBodyPart
    location: class msgsend
    MimeBodyPart mbp2 = new MimeBodyPart();
    ^
    msgsend.java:171: cannot find symbol
    symbol : class MimeMultipart
    location: class msgsend
    MimeMultipart mp = new MimeMultipart();
    ^
    msgsend.java:171: cannot find symbol
    symbol : class MimeMultipart
    location: class msgsend
    MimeMultipart mp = new MimeMultipart();
    ^
    msgsend.java:185: cannot find symbol
    symbol : variable Transport
    location: class msgsend
    Transport.send(msg);
    ^
    msgsend.java:193: cannot find symbol
    symbol : class Store
    location: class msgsend
    Store store = null;
    ^
    msgsend.java:195: cannot find symbol
    symbol : class URLName
    location: class msgsend
    URLName urln = new URLName(url);
    ^
    msgsend.java:195: cannot find symbol
    symbol : class URLName
    location: class msgsend
    URLName urln = new URLName(url);
    ^
    msgsend.java:212: cannot find symbol
    symbol : class Folder
    location: class msgsend
    Folder folder = store.getFolder(record);
    ^
    msgsend.java:218: cannot find symbol
    symbol : variable Folder
    location: class msgsend
    folder.create(Folder.HOLDS_MESSAGES);
    ^
    msgsend.java:220: cannot find symbol
    symbol : class Message
    location: class msgsend
    Message[] msgs = new Message[1];
    ^
    msgsend.java:220: cannot find symbol
    symbol : class Message
    location: class msgsend
    Message[] msgs = new Message[1];
    27 errors
    Here are the methods I have tried...
    1. Make sure you have most current version of Java
    2. Reinstall Java
    3. Attempt to compile in an IDE (Attempted in Eclipse 3.2)
    4. Set class path
    Some sources suggest "CLASSPATH" some suggest "CLASS PATH" as the variable name. I have tried both.
    Below is what the classpath looks like in bold.
    Variable Name: CLASS PATH
    Variable value: c:\download\javamail-1.4\mail.jar;C:\download\jaf-1.1\activation.jar;.
    I have double checked all folder names and copy pasted all entries to eliminate typos. Javamail-1.4 and jaf-1.1 are both located in c:\download which is the same location Class Path points to.
    Thank you very much for your input and effort. I can imagine how frusterating it is responding to 20million javamail posts :) (that may be a bit of an overstatement!)
    Thank you again!
    Irbi
    Message was edited by:
    irbi
    Message was edited by:
    irbi

    Yes - I have read that part of the README and did exactly as it has said in a previous attempt. I should have mentioned that here I'm sorry :)
    I moved the .jar files into the download folder and set the classpath exactly as the readme shows.
    When I do that the msgsend.java compiles correctly but it still does not run.
    Below is what happens.
    C:\download\javamail-1.4\demo>set CLASSPATH=%CLASSPATH%;c:\download\javamail-1.4
    \mail.jar;%CLASSPATH%;c:\download\jaf-1.1\activation.jar.
    C:\download\javamail-1.4\demo>javac msgsend.java
    C:\download\javamail-1.4\demo>java msgsend.java
    Exception in thread "main" java.lang.NoClassDefFoundError: msgsend/java
    C:\download\javamail-1.4\demo>
    I have tried fixing this error as well via forums and FAQs but it seems to be the most generic error.
    One suggestion was to clear your classpath. I tried this with a test hello world program which was giving the same error - "NoClassDefFoundError". By clearing the classpath I was able to get the hello world program to run without this error. But I can't just clear the classpath in this instance because it needs to point to mail.jar and activation.jar for the program to compile.
    Thanks again for all of your efforts. You are more appreciated than you know.

  • Getting javax.mail.AuthenticationFailedException: EOF on socket. Need Help

    I am trying to get hotmail emails and store in Oracle 10g database.
    When I am executing receivemail procedure from Oracle 10g database. I am getting following error.
    connect to ESIMSCO_UTIL_OWNER
    SQL> set serveroutput on
    SQL>
    SQL> Declare
    2 v_error_msg varchar2(10000);
    3 Begin
    4 v_error_msg:=receivemail('pop3.live.com', '<My email address>@hotmail.com', '<My email password>');
    5 dbms_output.put_line(v_error_msg);
    6 End;
    7 /
    javax.mail.AuthenticationFailedException: EOF on socket
    PL/SQL procedure successfully completed.
    SQL>
    I did following steps, but still I am getting this error. Can somebady help me to solve this problem.
    connect sys/<password>@esimsco as sysdba
    connect to sys
    SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 30 16:02:04 2012
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> begin
    1 dbms_java.grant_permission( 'ESIMSCO_UTIL_OWNER', 'SYS:java.util.PropertyPermission', '*', 'read,write' );
    2 commit;
    3 end;
    4 /
    PL/SQL procedure successfully completed.
    SQL> begin
    2 dbms_java.grant_permission(
    3 grantee => 'ESIMSCO_UTIL_OWNER',
    4 permission_type => 'SYS:java.net.SocketPermission',
    5 permission_name => '*',
    6 permission_action => 'connect,resolve'
    7 );
    8 end;
    9 /
    PL/SQL procedure successfully completed.
    SQL> begin
    2 dbms_java.grant_permission(
    3 grantee => 'ESIMSCO_UTIL_OWNER',
    4 permission_type => 'SYS:java.util.PropertyPermission',
    5 permission_name => '*',
    6 permission_action => 'read,write'
    7 );
    8 end;
    9 /
    PL/SQL procedure successfully completed.
    SQL> commit;
    Commit complete.
    SQL>
    Then I connect ESIMSCO_UTIL_OWNER.
    connect to ESIMSCO_UTIL_OWNER
    Create 2 tables.
    create table attachment(
    at_file varchar2(500),
    at_mimetype varchar2(500),
    at_attachment blob
    create table email (
    em_incident integer,
    em_from varchar2(1000),
    em_subject varchar2(1000),
    em_body nclob
    Then Create java source named receivemail.
    create or replace and compile java source named receivemail as
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.io.*;
    import java.sql.*;
    import sqlj.runtime.*;
    import oracle.sql.BLOB;
    public class ReceiveMail
    static void getAttachments(Message message, int incidentNo)
    throws MessagingException, IOException, SQLException {
    //String attachments = "";
    Object content = message.getContent();
    if (content instanceof Multipart)
    // -- Multi part message which may contain attachment
    Multipart multipart = (Multipart)message.getContent();
    // -- Loop through all parts of the message
    for (int i=0, n=multipart.getCount(); i<n; i++) {
    Part part = multipart.getBodyPart(i);
    String disposition = part.getDisposition();
    if ((disposition != null) &&(disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE))) {
    //-- This part is a file attachment
    String fileName = incidentNo+"_"+part.getFileName().replace(' ','_');
    System.out.println("FILE: " + fileName);
    String contentType = part.getContentType();
    String mimeType = contentType.substring(0,contentType.indexOf(";"));
    System.out.println("FILETYPE: " + mimeType);
    InputStream is = part.getInputStream();
    // -- To work with a BLOB column you have to insert a record
    // -- with an emptly BLOB first.
    #sql { insert into attachment(at_file, at_mimetype, at_attachment)
    values (:fileName, :mimeType, empty_blob()) };
    // -- Retrieve the BLOB
    BLOB attachment = null;
    #sql { select at_attachment into :attachment
    from attachment where at_file = :fileName };
    // -- Fill the BLOB
    OutputStream os = attachment.getBinaryOutputStream();
    int j;
    while ((j = is.read()) != -1) {
    os.write(j);
    is.close();
    os.close();
    // -- Set the BLOB by updating the record
    #sql { update attachment set at_attachment = :attachment
    where at_file = :fileName };
    static String getPlainTextBody(Message message)
    throws MessagingException, IOException
    Object content = message.getContent();
    if (message.isMimeType("text/plain")) {
    // -- Message has plain text body only
    System.out.println("SIMPLE TEXT");
    return (String) content;
    } else if (message.isMimeType("multipart/*")) {
    // -- Message is multipart. Loop through the message parts to retrieve
    // -- the body.
    Multipart mp = (Multipart) message.getContent();
    int numParts = mp.getCount();
    System.out.println("MULTIPART: "+numParts);
    for (int i = 0; i < numParts; ++i) {
    System.out.println("PART: "+mp.getBodyPart(i).getContentType());
    if (mp.getBodyPart(i).isMimeType("text/plain")) {
    // -- Return the plain text body
    return (String) mp.getBodyPart(i).getContent();
    } else if (mp.getBodyPart(i).isMimeType("multipart/*")) {
    // -- Body is also multipart (both plain text and html).
    // -- Loop through the body parts to retrieve plain text part.
    MimeMultipart mmp = (MimeMultipart) mp.getBodyPart(i).getContent();
    int numBodyParts = mmp.getCount();
    System.out.println("MULTIBODYPART: "+numBodyParts);
    for (int j = 0; j < numBodyParts; ++j) {
    System.out.println("BODYPART: "+mmp.getBodyPart(j).getContentType());
    if (mmp.getBodyPart(j).isMimeType("text/plain")) {
    // -- Return the plain text body
    return (String) mmp.getBodyPart(j).getContent();
    return "";
    } else {
    System.out.println("UNKNOWN: "+message.getContentType());
    return "";
    static void saveMessage(Message message)
    throws MessagingException, IOException, SQLException
    //String body = "";
    int incidentNo;
    // -- Get a new incident number
    #sql { select seq_incident.nextval into :incidentNo from dual };
    // -- Get the header information
    String from = ((InternetAddress)message.getFrom()[0]).getAddress();
    System.out.println("FROM: "+ from);
    String subject = message.getSubject();
    System.out.println("SUBJECT: "+subject);
    // -- Retrieve the plain text body
    String body = getPlainTextBody(message);
    // -- Store the message in the email table
    #sql { insert into email (em_incident, em_from, em_subject, em_body)
    values (:incidentNo, :from, :subject, :body) };
    // -- Retrieve the attachments
    getAttachments(message, incidentNo);
    #sql { commit };
    // -- Mark message for deletion
    // message.setFlag(Flags.Flag.DELETED, true);
    public static String Receive(String POP3Server, String usr, String pwd)
    Store store = null;
    Folder folder = null;
    try
    // -- Get hold of the default session --
    Properties props = System.getProperties();
    props.put("mail.pop3.connectiontimeout", "60000");
    Session session = Session.getDefaultInstance(props, null);
    // -- Get hold of a POP3 message store, and connect to it --
    store = session.getStore("pop3");
    store.connect(POP3Server,995, usr, pwd);
    System.out.println("Connected");
    // -- Try to get hold of the default folder --
    folder = store.getDefaultFolder();
    if (folder == null) throw new Exception("No default folder");
    // -- ...and its INBOX --
    folder = folder.getFolder("INBOX");
    if (folder == null) throw new Exception("No POP3 INBOX");
    // -- Open the folder for read_write (to be able to delete message) --
    folder.open(Folder.READ_WRITE);
    // -- Get the message wrappers and process them --
    Message[] msgs = folder.getMessages();
    for (int msgNum = 0; msgNum < msgs.length; msgNum++){
    saveMessage(msgs[msgNum]);
    System.out.println("No more messages");
    return ("SUCCESS");
    catch (Exception ex){
    ex.printStackTrace();
    return ex.toString();
    finally{
    // -- Close down nicely --
    try{
    // close(true), to expunge deleted messages
    if (folder!=null) folder.close(true);
    if (store!=null) store.close();
    catch (Exception ex){
    //ex.printStackTrace();
    return ex.toString();
    Then create function receivemail.
    create or replace function receivemail(pop3_server in string,
    pop3_usr in string,
    pop3_pwd in string)
    return varchar2
    is language java name
    'ReceiveMail.Receive(java.lang.String,
    java.lang.String,
    java.lang.String) return String';
    And then trying to execute function receivemail, but I am getting following error.
    SQL> set serveroutput on
    SQL>
    SQL> Declare
    2 v_error_msg varchar2(10000);
    3 Begin
    4 v_error_msg:=receivemail('pop3.live.com', '<Hotmail email address>@hotmail.com', 'Hotmail password');
    5 dbms_output.put_line(v_error_msg);
    6 End;
    7 /
    javax.mail.AuthenticationFailedException: EOF on socket
    PL/SQL procedure successfully completed.
    SQL>
    I am requesting, please help me to solve this problem.
    I will be very thankful for your kind help and support.
    Amol......
    Edited by: Amol Karyakarte on 31-May-2012 7:27 AM

    Hello,
    I don't think this is the right forum, as this question seems to have nothing to do with the Oracle Forms tool.
    You'd better ask it in the database forum.
    Francois

  • Help to solve javax.mail.AuthenticationFailedException: EOF on socket

    I am trying to get hotmail emails and store in Oracle 10g database.
    When I am executing receivemail procedure from Oracle 10g database. I am getting following error.
    connect to ESIMSCO_UTIL_OWNER
    SQL> set serveroutput on
    SQL>
    SQL> Declare
    2 v_error_msg varchar2(10000);
    3 Begin
    4 v_error_msg:=receivemail('pop3.live.com', '<My email address>@hotmail.com', '<My email password>');
    5 dbms_output.put_line(v_error_msg);
    6 End;
    7 /
    javax.mail.AuthenticationFailedException: EOF on socket
    PL/SQL procedure successfully completed.
    SQL>
    I did following steps, but still I am getting this error. Can somebady help me to solve this problem.
    connect sys/<password>@esimsco as sysdba
    connect to sys
    SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 30 16:02:04 2012
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> begin
    1 dbms_java.grant_permission( 'ESIMSCO_UTIL_OWNER', 'SYS:java.util.PropertyPermission', '*', 'read,write' );
    2 commit;
    3 end;
    4 /
    PL/SQL procedure successfully completed.
    SQL> begin
    2 dbms_java.grant_permission(
    3 grantee => 'ESIMSCO_UTIL_OWNER',
    4 permission_type => 'SYS:java.net.SocketPermission',
    5 permission_name => '*',
    6 permission_action => 'connect,resolve'
    7 );
    8 end;
    9 /
    PL/SQL procedure successfully completed.
    SQL> begin
    2 dbms_java.grant_permission(
    3 grantee => 'ESIMSCO_UTIL_OWNER',
    4 permission_type => 'SYS:java.util.PropertyPermission',
    5 permission_name => '*',
    6 permission_action => 'read,write'
    7 );
    8 end;
    9 /
    PL/SQL procedure successfully completed.
    SQL> commit;
    Commit complete.
    SQL>
    Then I connect ESIMSCO_UTIL_OWNER.
    connect to ESIMSCO_UTIL_OWNER
    Create 2 tables.
    create table attachment(
    at_file varchar2(500),
    at_mimetype varchar2(500),
    at_attachment blob
    create table email (
    em_incident integer,
    em_from varchar2(1000),
    em_subject varchar2(1000),
    em_body nclob
    Then Create java source named receivemail.
    create or replace and compile java source named receivemail as
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.io.*;
    import java.sql.*;
    import sqlj.runtime.*;
    import oracle.sql.BLOB;
    public class ReceiveMail
    static void getAttachments(Message message, int incidentNo)
    throws MessagingException, IOException, SQLException {
    //String attachments = "";
    Object content = message.getContent();
    if (content instanceof Multipart)
    // -- Multi part message which may contain attachment
    Multipart multipart = (Multipart)message.getContent();
    // -- Loop through all parts of the message
    for (int i=0, n=multipart.getCount(); i<n; i++) {
    Part part = multipart.getBodyPart(i);
    String disposition = part.getDisposition();
    if ((disposition != null) &&(disposition.equals(Part.ATTACHMENT) || disposition.equals(Part.INLINE))) {
    //-- This part is a file attachment
    String fileName = incidentNo+"_"+part.getFileName().replace(' ','_');
    System.out.println("FILE: " + fileName);
    String contentType = part.getContentType();
    String mimeType = contentType.substring(0,contentType.indexOf(";"));
    System.out.println("FILETYPE: " + mimeType);
    InputStream is = part.getInputStream();
    // -- To work with a BLOB column you have to insert a record
    // -- with an emptly BLOB first.
    #sql { insert into attachment(at_file, at_mimetype, at_attachment)
    values (:fileName, :mimeType, empty_blob()) };
    // -- Retrieve the BLOB
    BLOB attachment = null;
    #sql { select at_attachment into :attachment
    from attachment where at_file = :fileName };
    // -- Fill the BLOB
    OutputStream os = attachment.getBinaryOutputStream();
    int j;
    while ((j = is.read()) != -1) {
    os.write(j);
    is.close();
    os.close();
    // -- Set the BLOB by updating the record
    #sql { update attachment set at_attachment = :attachment
    where at_file = :fileName };
    static String getPlainTextBody(Message message)
    throws MessagingException, IOException
    Object content = message.getContent();
    if (message.isMimeType("text/plain")) {
    // -- Message has plain text body only
    System.out.println("SIMPLE TEXT");
    return (String) content;
    } else if (message.isMimeType("multipart/*")) {
    // -- Message is multipart. Loop through the message parts to retrieve
    // -- the body.
    Multipart mp = (Multipart) message.getContent();
    int numParts = mp.getCount();
    System.out.println("MULTIPART: "+numParts);
    for (int i = 0; i < numParts; ++i) {
    System.out.println("PART: "+mp.getBodyPart(i).getContentType());
    if (mp.getBodyPart(i).isMimeType("text/plain")) {
    // -- Return the plain text body
    return (String) mp.getBodyPart(i).getContent();
    } else if (mp.getBodyPart(i).isMimeType("multipart/*")) {
    // -- Body is also multipart (both plain text and html).
    // -- Loop through the body parts to retrieve plain text part.
    MimeMultipart mmp = (MimeMultipart) mp.getBodyPart(i).getContent();
    int numBodyParts = mmp.getCount();
    System.out.println("MULTIBODYPART: "+numBodyParts);
    for (int j = 0; j < numBodyParts; ++j) {
    System.out.println("BODYPART: "+mmp.getBodyPart(j).getContentType());
    if (mmp.getBodyPart(j).isMimeType("text/plain")) {
    // -- Return the plain text body
    return (String) mmp.getBodyPart(j).getContent();
    return "";
    } else {
    System.out.println("UNKNOWN: "+message.getContentType());
    return "";
    static void saveMessage(Message message)
    throws MessagingException, IOException, SQLException
    //String body = "";
    int incidentNo;
    // -- Get a new incident number
    #sql { select seq_incident.nextval into :incidentNo from dual };
    // -- Get the header information
    String from = ((InternetAddress)message.getFrom()[0]).getAddress();
    System.out.println("FROM: "+ from);
    String subject = message.getSubject();
    System.out.println("SUBJECT: "+subject);
    // -- Retrieve the plain text body
    String body = getPlainTextBody(message);
    // -- Store the message in the email table
    #sql { insert into email (em_incident, em_from, em_subject, em_body)
    values (:incidentNo, :from, :subject, :body) };
    // -- Retrieve the attachments
    getAttachments(message, incidentNo);
    #sql { commit };
    // -- Mark message for deletion
    // message.setFlag(Flags.Flag.DELETED, true);
    public static String Receive(String POP3Server, String usr, String pwd)
    Store store = null;
    Folder folder = null;
    try
    // -- Get hold of the default session --
    Properties props = System.getProperties();
    props.put("mail.pop3.connectiontimeout", "60000");
    Session session = Session.getDefaultInstance(props, null);
    // -- Get hold of a POP3 message store, and connect to it --
    store = session.getStore("pop3");
    store.connect(POP3Server,995, usr, pwd);
    System.out.println("Connected");
    // -- Try to get hold of the default folder --
    folder = store.getDefaultFolder();
    if (folder == null) throw new Exception("No default folder");
    // -- ...and its INBOX --
    folder = folder.getFolder("INBOX");
    if (folder == null) throw new Exception("No POP3 INBOX");
    // -- Open the folder for read_write (to be able to delete message) --
    folder.open(Folder.READ_WRITE);
    // -- Get the message wrappers and process them --
    Message[] msgs = folder.getMessages();
    for (int msgNum = 0; msgNum < msgs.length; msgNum++){
    saveMessage(msgs[msgNum]);
    System.out.println("No more messages");
    return ("SUCCESS");
    catch (Exception ex){
    ex.printStackTrace();
    return ex.toString();
    finally{
    // -- Close down nicely --
    try{
    // close(true), to expunge deleted messages
    if (folder!=null) folder.close(true);
    if (store!=null) store.close();
    catch (Exception ex){
    //ex.printStackTrace();
    return ex.toString();
    Then create function receivemail.
    create or replace function receivemail(pop3_server in string,
    pop3_usr in string,
    pop3_pwd in string)
    return varchar2
    is language java name
    'ReceiveMail.Receive(java.lang.String,
    java.lang.String,
    java.lang.String) return String';
    And then trying to execute function receivemail, but I am getting following error.
    SQL> set serveroutput on
    SQL>
    SQL> Declare
    2 v_error_msg varchar2(10000);
    3 Begin
    4 v_error_msg:=receivemail('pop3.live.com', '<Hotmail email address>@hotmail.com', 'Hotmail password');
    5 dbms_output.put_line(v_error_msg);
    6 End;
    7 /
    javax.mail.AuthenticationFailedException: EOF on socket
    PL/SQL procedure successfully completed.
    SQL>
    I am requesting, please help me to solve this problem.
    I will be very thankful for your kind help and support.
    Amol......

    Amol Karyakarte wrote:
    I am requesting, please help me to solve this problem.
    I will be very thankful for your kind help and support.
    Amol......since you asked for it:
    http://lmgtfy.com/?q=javax.mail.AuthenticationFailedException
    First hit
    Session session = Session.getDefaultInstance(props, null);Is null correct?
    Regards

  • Reading Inbox - javax.mail.MessagingException: Connect failed;

    I get an error message while trying to read emails by connecting to a company mailbox. The message is as follows:
    javax.mail.MessagingException: Connect failed;
    nested exception is:
         java.net.ConnectException: Connection refused: no further information
         boolean com.sun.mail.pop3.POP3Store.protocolConnect(java.lang.String, int, java.lang.String, java.lang.String)
         void javax.mail.Service.connect(java.lang.String, int, java.lang.String, java.lang.String)
         void javax.mail.Service.connect(java.lang.String, java.lang.String, java.lang.String)
         void GetMessageExample.main(java.lang.String[])
    The code is very simple and as follows:
    import java.io.*;
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class GetMessageExample {
    public static void main (String args[]) throws Exception {
    String host = "companyname.com";
    String username = "user";
    String password = "xxxx";
    try{
    // Create empty properties
    Properties props = new Properties();
    // Get session
    Session session = Session.getInstance(props, null);
    // Get the store
    Store store = session.getStore("pop3");
    store.connect(host, username, password);
    // Get folder
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_ONLY);
    BufferedReader reader = new BufferedReader (
    new InputStreamReader(System.in));
    // Get directory
    Message message[] = folder.getMessages();
    for (int i=0, n=message.length; i<n; i++) {
    System.out.println(i + ": " + message.getFrom()[0]
    + "\t" + message[i].getSubject());
    // Close connection
    folder.close(false);
    store.close();
    } catch (Exception e) {
    e.printStackTrace();
    I have a two part question:
    1. At home I am using a dial-up connection it works when I change the settings to an email account as provided by the local ISP.
    I have tried it with both "pop3" and "imap" in
    Store store = session.getStore("pop3");
    for the company email but it does not work.
    Is this a problem with company security? Maybe firewall/proxy error? If so how do I get around it?
    2. Also, when I am in the office (LAN used to connect to Internet) I cannot even get a connection to the ISP account - similar problem or different?
    Any thoughts and help most appreciated.
    Thanks in advance,
    Mark

    It could be that the mail server is not accepting connections from the machine you are on. Have you tried using Outlook Express or the Netscape email client to connect to the server/account from the machine that is getting the failure?

Maybe you are looking for

  • I forgot the password icloud. How can i get it back with my alternate email?

    I forgot my apple ID and iCloud password. But i still remember my alternate email (which is a gmail). I have already request the the reset email but i didnt receive anything from apple. I'm worry that the reset email will be sent to primary email (wh

  • Adobe Distiller 11.0.9 - Unable to find "Adobe PDF" resource files "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\AMT"

    When I attempt to launch Adobe Distiller Pro 11.0.929, I get an error: Unable to find "Adobe PDF" resource files "C:\Program Files\Adobe\Acrobat 9.0\Acrobat\AMT" You must have Administrator privileges to install these files. Please contact your local

  • Can i use id on html:select syntax...

    Hi, i am using the following code to take data from the database directly to a dropdown box. <html:select property="lddate" style = "width:160"> <html:option value="--SELECT--">SELECT</html:option> <html:options collection="loadDateList" name="almRec

  • How to set a Conditional Format in a Crosstab

    Hello, I think I have a straight forward problem, but after reading the instructions I can't seem to make this work. I am using BI 10.1.3.4.1 I have a crosstab that I have build as an RTF template that looks like the following name rolename, priv nam

  • The Streaming example is crashing Firefox

    I just tried the Streaming example in this link http://mediapm.edgesuite.net/osmf/swf/ExamplePlayer.swf This is a build of the OSMF example showing all the possibilities. The streaming link is freezing the swf When I trying to update my sample video