Error using javax.mail package

Hi,
I have included the package javax.mail.* in my code.I have downloaded
jaf 1.0.2 and javamail 1.1.3 from the Sun Microsystems website.
When i try to compile my code i get the error message:
com/voxspectrum/ccvox/EmailServer.java:55: cannot resolve symbol
symbol : class MimeMessage
location: class com.voxspectrum.ccvox.EmailServer
javax.mail.Message msg = new MimeMessage(session);
I am using JDK ver 1.3.1_02. What should i set my path and classpath as, if i am using javax.mail package?
Please could you help me out with this problem!

Hi Nisha
You need to include the path to the mail.jar and activation.jar files in your classpath.
How you do it depends on the OS you are running on
in Windows 95 /98 the easiest way is to edit the autoexec.bat file and add the settings to your already existing classpath statement i.e.
set CLASSPATH=%CLASSPATH%;C:\richard\javamail-1.3\mail.jar C:\richard\jaf-1.0.2\activation.jar
(excuse the word wrapping) then reboot
on Linux / Solaris edit the .profile file for your user and set the CLASSPATH variable to
CLASSPATH=$CLASSPATH:<pathtofile>/mail.jar:<pathtofile>/activation.jar
export CLASSPATH
and that should do it
Hope this helps

Similar Messages

  • Error when using javax.script package

    Hi
    I want to call a javascript method from a .js file from .java class.
    when i searched, i came to understand that using jdk1.6 i can use javax.script package tht provide me what i needed.
    using the reply i got from i earlier post, i tried one example.
    public void show() {
    ScriptEngineManager engineMgr = new ScriptEngineManager();
    ScriptEngine engine= engineMgr.getEngineByName("JavaScript");
    try {
    engine.eval(new FileReader("D:/ShowScript.js"));
    Invocable invocableEngine = (Invocable) engine;
    //show_message is my function in ShowScript.js file
    invocableEngine.invokeFunction("show_message",null);
    } catch (Exception e) {
    e.printStackTrace();
    ShowScript.js
    function show_message()
    println("===> hi");
    alert("hi");
    When i execute my program, im getting the following error
    javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "alert" is not defined. ( #8) in at line number 8
    at com.sun.script.javascript.RhinoScriptEngine.invoke(RhinoScriptEngine.java:184)
    at com.sun.script.javascript.RhinoScriptEngine.invokeFunction(RhinoScriptEngine.java:142)
    at testbuiltin.backing.Show_alert.show(Show_alert.java:81)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
    When i remove the alert() from the js file, the println is working. But what i neede is the alert.
    Can anyone plz help me to solve this problem.

    As you're talking about "backing beans", are you using JSF?
    After all, this is definitely not the way to let Java and JS interact with each other. Java runs at the server side. JS runs at the client side. Java can write JS code to the response, but definitely cannot call it. JS can access the HTML DOM and invoke requests to the server (form.submit() and AJAX and so on) and send parameters along the request, but definitely cannot call Java classes and methods independently. Nothing more and nothing less than that.

  • WLS5.1 SP8: using javax.mail

    Hi All,
    I've just managed to use the javax.mail package to send email from a session
    bean, but I'm not happy with the way I did it and I had to hack the
    solution, rather than follow the recommended way:
    In my weblogic.properties file, I have;
    weblogic.resource.MailSession.weblogic.resource.mail.EBCSession=\
    mail.from=[email protected], \
    mail.host=mail.fluid.com.au
    which seems to be correct according to
    http://www.weblogic.com/docs51/classdocs/API_ejb/EJB_environment.html#102218
    2
    When I start WLS, it indicated that it's bound the JNDI name without error
    However, in my session bean, I kept getting a runtime error as the session
    was trying to connect to a server on localhost, instead of
    "mail.fluid.com.au". In other words, it didn't seem to be using the
    mail.host setting in weblogic.properties.
    I managed to solve the problem by doing this:
    Properties props = new Properties();
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.host", Utility.getProperty("ebc.mail.host"));
    // use mail address from HTML form for from address
    props.put("mail.from", "[email protected]");
    and sending the props object when creating the session AND THIS WORKED!
    I'd prefer to configure the mail session only in weblogic.properties, so is
    there another step I need to take to make WLS see/use the mail.host I have
    set in weblogic.properties?
    Thanks all for your time.
    byeeeeeeeeeeeeeeeeeeeee

    The 'nice' way to do what you want is to have your realm implement
    the ManageableRealm interface and call those methods instead of
    changing the database directly from the Bean.
    Also make sure your realm has a way to refresh it's cache (if you
    use one) when Users/Groups/ACLs are added/changed in your underlying
    data store.
    -Don
    "Andy Marks" <[email protected]> wrote:
    Hi All,
    I've hacked the rdbmsrealm example from the standard WLS5.1
    install to use
    the schema in my Oracle 8.1.6 database instread of the
    cloudscape db, and
    everything is fine. However...
    I'm a little in the dark about how much interaction my
    EJBs should have with
    the realm? I initially had a bean which controlled user
    creation by
    populating the same database table that is now mapped
    to by my
    realm.properties. Should I now delegate the user creation
    to the realm
    classes instead of my bean?
    I've looked through what I think is all the documentation,
    but still cannot
    really find the "how is it used" information I require.
    byeeeeeeeeeeeeeeee
    Thanks in advance.

  • 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

  • Error: SHA1 digest error for javax/mail/Authenticator.class

    I am using javax.mail api to sending emails.
    when I calls main method of the class to send email its works perfect, but when I imports the same class in jsp its shows me above said error.
    My email server requires authentication before sending mails.
    please guide me how to use this class in jsp .
    class code is as below :
    =========================
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.io.*;
    public class SendMailUsingAuthentication
    private static final String SMTP_HOST_NAME = "myserver.smtphost.com";
    private static final String SMTP_AUTH_USER = "myusername";
    private static final String SMTP_AUTH_PWD = "mypwd";
    private static final String emailMsgTxt = "Online Order Confirmation Message. Also include the Tracking Number.";
    private static final String emailSubjectTxt = "Order Confirmation Subject";
    private static final String emailFromAddress = "[email protected]";
    // Add List of Email address to who email needs to be sent to
    private static final String[] emailList = {"[email protected]", "[email protected]"};
    public static void main(String args[]) throws Exception
    SendMailUsingAuthentication smtpMailSender = new SendMailUsingAuthentication();
    smtpMailSender.postMail( emailList, emailSubjectTxt, emailMsgTxt, emailFromAddress);
    System.out.println("Sucessfully Sent mail to All Users");
    public void postMail( String recipients[ ], String subject,
    String message , String from) throws MessagingException
    boolean debug = false;
    //Set the host smtp address
    Properties props = new Properties();
    props.put("mail.smtp.host", SMTP_HOST_NAME);
    props.put("mail.smtp.auth", "true");
    Authenticator auth = new SMTPAuthenticator();
    Session session = Session.getDefaultInstance(props, auth);
    session.setDebug(debug);
    // create a message
    Message msg = new MimeMessage(session);
    // set the from and to address
    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);
    // Setting the Subject and Content Type
    msg.setSubject(subject);
    msg.setContent(message, "text/plain");
    Transport.send(msg);
    * SimpleAuthenticator is used to do simple authentication
    * when the SMTP server requires it.
    private class SMTPAuthenticator extends javax.mail.Authenticator
    public PasswordAuthentication getPasswordAuthentication()
    String username = SMTP_AUTH_USER;
    String password = SMTP_AUTH_PWD;
    return new PasswordAuthentication(username, password);

    Find all the jar files under Tomcat's installation directory and all the jar files in the jre/lib/ext directory.
    Make sure only one of them includes javax.mail.* classes.
    Note that setting CLASSPATH to a directory does not cause all jar files in that directory to be loaded.
    Finally, make sure Eclipse isn't copying the class files out of mail.jar and packaging them with your
    application.

  • Problems sending email using javax.mail.*

    I need to send an email from an application I am working on. I am using the features of the javax.mail package to do so. In looking at the code I am unsure why this is not working. This is my first time using this package so it might be something silly I am missing so any of your thoughts are appreciated. The code is as follows:
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    public class EmailTester {
         public static void main(String[] args) {
              try {
                   //Set the smtp address
                   Properties props = new Properties();
                   props.put("mail.smtp.host", args[0] );
                   // get the default Session
                   Session session = Session.getDefaultInstance(props, null);
                   session.setDebug(true);
                   // create a message for this session
                   Message msg = new MimeMessage(session);
                   // set the from and to address
                   InternetAddress from =
                        new InternetAddress( args[1] );
                   InternetAddress[] to = new InternetAddress[1];
                   to[0] = new InternetAddress( args[2] );
                   msg.setFrom(from);
                   msg.setRecipients(Message.RecipientType.TO, to);
                   // set the subject and content type
                   msg.setSubject("subject");
                   msg.setContent("this is my test email", "text/plain");
                   // send the email
                   Transport.send(msg);
              catch (MessagingException me) {

    I have an EMail class that I use at:
    http://www.discoverteenergy.com/files/EMail.java
    Feel free to use it or compare against your code to see what is different.

  • SHA1 digest error for javax/mail/MessagingException

    java.lang.SecurityException: SHA1 digest error for javax/mail/MessagingException.class
         at sun.security.util.ManifestEntryVerifier.verify(ManifestEntryVerifier.java:194)
         at java.util.jar.JarVerifier.processEntry(JarVerifier.java:201)
         at java.util.jar.JarVerifier.update(JarVerifier.java:188)
         at java.util.jar.JarVerifier$VerifierStream.read(JarVerifier.java:411)
         at sun.misc.Resource.getBytes(Resource.java:97)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:256)
         at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    Exception in thread "main"
    What could be the problem for this error Exception ???
    Thanks and Regards.

    Hi!
    Do you use some plugins with eclipse IDE, like Tomcat by example or other plugins ... ?
    If yes, update mail.jar and activation.jar inside Tomcat or in your lib project Eclipse...
    You have a conflict with the class loader that check for security for class javax/mail/MessagingException
    See you Manifest.mf inside mail.jar :
    (old version here...)
    Manifest-Version: 1.0
    Implementation-Version: 1.4
    Specification-Title: JavaMail(TM) API Design Specification
    Specification-Version: 1.3
    Implementation-Title: javax.mail
    Extension-Name: javax.mail
    Created-By: 1.5.0 (Sun Microsystems Inc.)
    Implementation-Vendor-Id: com.sun
    Implementation-Vendor: Sun Microsystems, Inc.
    Specification-Vendor: Sun Microsystems, Inc.
    SCCS-ID: @(#)javamail.mf     1.6 05/12/09
    Name: javax/mail/search/SearchTerm.class
    SHA1-Digest: SwGnDhIUmpZhfhq/FKkCQ9nD7ZE=
    Name: javax/mail/SendFailedException.class
    SHA1-Digest: XdCEygaIZQB9YrH2WIr4nPRYYk0=
    Name: javax/mail/MessagingException.class
    SHA1-Digest: lfjX30OQ88v/n9G9fTJGqjFmPd0=
    regards,

  • Getting free download of javax.mail package

    where can i get free download for javax.mail package
    Which can be used for retrieving mails/attachments

    http://java.sun.com/products/javamail/index.html

  • Setting Importance Level for a email message using javax.mail.* API

    Setting Importance Level for a email message using javax.mail.* API
    From what I understand we can set Flag on Email Message. How can we set Importance Leve: High/Low for an email message?
    Thanks
    Purvi

    Most of the message Flags work only for IMAP mailboxes. POP3 supports only the DELETED flag. It must be understood that Javamail is a framework which provides all the features available in a standard mailing system. But whether or not a particular feature works is a functionality of the particular implementation being used.
    Thus for example POP3 cannot differentiate read from unread messages in a mailbox though Javamail provides that feature.

  • Tutorials for using javax.help package api's

    hi! i m woking on javax.help package for my project nowadays. i will be grateful if someone can guide me that where i can find sample codes and tutorials for using api's in this package.
    thanks. bye.

    tutorials for using javax.help package api's

  • I want javax.mail package

    Hi all,
    Please tell me the location where I need to download the javax.mail package.
    Thanks
    Anand

    http://java.sun.com/products/javamail/index.html

  • Problem using Javax.Mail API

    Hi Experts,
    I am using Javax.mail API to send an email through java application. But i am facing an issue when i am deploying the java application in SAP WAS.
    I have assigned values in SMTP Host ,Port, and InternetAddress and deployed to WAS. But when i deploy this java class again in WAS with changing the values for SMTP Host ,Port and InternetAddress and putting in Properties object ,its always picking the values set at first time.
    Can anyone tell me whats wrong with following code .
    Properties prpt = new Properties();
    if (host == null)
    host=token[0];
    prpt.put("mail.smtp.host",host);
    prpt.put("mail.smtp.sendpartial", "true");
    if (port == null)
    port=token[1];
    prpt.put("mail.smtp.port", port);
    Session session1=Session.getDefaultInstance(prpt, null);
    MimeMessage message=new MimeMessage(session1);
    message.setFrom(new InternetAddress(emailId"));
    Thanks in advance.

    Hi
    I hope follow similar answered thread  will help you.
    1. [Javamail Client Service   |Javamail Client Service;
    2.[Sending Email   |Sending Email;
    Best Regard
    Satish Kumar

  • Javax.mail. package not recognised

    Hi people!!!!
    Please help me out as I am new to j2ee/JavaMail
    I have the j2ee sdk 1.4 installed as well as j2se1.4.2/netbeans conbundle.
    I would create to a simple application that sends an email. However, the compiler doesn't recognise the javax.mail.* and javax.mail.internet.* packages.
    When I type j2ee -verbose at the command prompt it states that it doesn't recognise the command.
    I have set my environment variables as follows:
    J2EE_PATH:      C:\Sun\AppServer\
    J2EE_HOME:     C:\Sun\AppServer\
    JAVA_HOME:     C:\Program Files\j2sdk_nb\j2sdk1.4.2\
    System Variables:
    CLASSPATH:     C:\Sun\AppServer\lib\j2ee.jar
    PATH:     %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\MSSQL7\BINN;C:\Program Files\j2sdk_nb\j2sdk1.4.2\bin\;C:\TOOLS\Tomcat4.1\webapps\Intranet\WEB-INF\classes\;C:\Sun\AppServer\bin\
    Do perhaps know what I have not done correctly....
    Thanks, any assistance will be much appreciated.
    You may email your answers to me at [a href='mailto:[email protected]'][email protected][\a] if you wish
    Regards
    Ushanta

    Hey I have added the mail.jar file to my classpath and I don't get this error any more.... Unfortunately, though I get a java.lang.NoClassDefFoundError Exception in thread 'main'
    I do have a main method, here is my code:
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.Properties;
    import java.io.*;
    * @author user
    public class SimpleSender {
    /** Creates a new instance of SimpleSender */
    public SimpleSender() {
    public static void main(String[] args) {
    if (args.length != 3) {
    System.out.println("ERROR");
    System.exit(1);
    String host = args[0];
    String to = args[1];
    String from = args[2];
    String contentType = "text/html";
    Properties props = System.getProperties();
    props.put("mail.smtp.host", args[0]);
    try{
    Session session = Session.getDefaultInstance(props, null);
    MimeMessage message = new MimeMessage(session);
    message.setSubject("Hello");
    message.setFrom(new InternetAddress(from));
    message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
    String text = "<h1>testing email</h1>";
    message.setContent(text, "text/html");
    Transport.send(message);
    } catch (MessagingException e) {
    e.printStackTrace();
    }

  • SHA1 digest error for javax/mail/Message.class

    it's been 4 hrs that i am striving to get around this .....Does any body has any idea why this error appears and how to remedy it ....
    help will be much much appreciated....

    Either:
    1. Your mail.jar is corrupted, or
    2. You have more than one copy of the javax.mail.Message class in your CLASSPATH.

  • Newbie Class Loader Errors on javax/mail/Part

    I'm a newb to Java but have experience in other languages. I built a command line application using Eclipse 3.0 that runs great in Eclipse. The app takes incoming .eml files from a WinXP server's drop dir, parses the attachments and stashes them as blobs in a database. I've jarred my .class files together and set my Class-Path attributes in the Manifest file and the proggie looks like it wants to run until I get to line 102 in main() where I call on one of my helper classes.
    The line reads:
    MimeWalker objMime = new MimeWalker();
    In my MimeWalker class upon instantiation, I have the initialization routine set up some class objects as follows:
    public class MimeWalker {
         private int w;
         private boolean headerParsed;
         private String subject;
         private Address from;
         private Address to[];
         private Date sentDate;
         private InputStream bodyCopy;
         private String bodyMimeType;
         private Properties props;
         private Session mailSession;
         private MimeMessage message;
         private Multipart mPart;
         private int partCount;
         private String partContentType;
         private String partDisposition;
         private String partFilename;
         private String partMimeType;
         private InputStream partData;
         /* This method sets the private variables to the necessary values
         * to open a file at this point.
         public MimeWalker(){
              this.props = System.getProperties();
              this.props.put("mail.host", "smtp.dummydomain.com");
              this.props.put("mail.transport.protocol", "smtp");
              this.mailSession = Session.getDefaultInstance(this.props, null);
    I have imported javax.mail.*; and javax.mail.internet.*; in my MimeWalker class and since this is the first point in the program where a call to that library is used this is where it's bombing. The bomb message I get is as follows:
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Part
    at com.jwt.emailProc.EmailProcessor.main(EmailProcessor.java:102)
    I've been dealing with this off anf on for almost 2 days now and have searched countless websites for some insight. I have two hypothesis at this point but don't know how valid either is.
    1. javax/mail/Part is actually an Interface and not a class so could that be causing my problems? If so how?
    2. Because the mail API relys on the activation.jar library there's some anomaly that is preventing it from working properly. activation.jar just like all the other necessary libraries are located in ./stuff/*.jar in relation to my emailProc.jar application.
    Thanks in advance for any help you can provide!
    --James                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    I found out what my problem was. So for all you Java newbs like me remember this!
    In the MANIFEST.MF file if you have a line that is longer than 72 bytes (not characters... bytes) the end of the line is scrapped.
    That was my problem. As soon as I broke my Class-Path line down into 3 seperate lines with each line starting with a single space and each previous line ending with a single space and cr my app just started working.
    The JAR tutorial on this site is a great resource! I advise anyone attempting to Jar their distributions to use it.
    -- James

Maybe you are looking for