title: send email in java by outlook
body: <p>I found a package that might help me send mails from my java using my outlook and it is called Java Outlook Connector.
  i put the code and compile normally but when i send the email an error occurs.
  this error is that java didnt find my class imported. on the other hand i imported the classes carefully and inserted them in my Jdeveloper library but still the error is appearing.
  i think mainly the error now is due to not setting the java library path correctly. how can i solve this problem?</p>
  
  <p>Below is my code and my error</p>
  
  <p>Thank you</p>
  
  <pre><code>import com.moyosoft.connector.com.*;
  import com.moyosoft.connector.exception.*;
  import com.moyosoft.connector.ms.outlook.*;
  import com.moyosoft.connector.ms.outlook.folder.*;
  import com.moyosoft.connector.ms.outlook.item.*;
  import com.moyosoft.connector.ms.outlook.mail.*;
  
      public void testbutton_action() {
  
  
  
         try
                {
  
  
  
           //   System.load("C:\\Program Files (x86)\\Java\\jdk1.7.0_71\\bin\\moyocore_x64.dll");
  
         //  Outlook.setLibraryPath("C:\\Program Files (x86)\\Java\\jdk1.7.0_71\\bin\\moyocore.dll");
  
  
                   // Outlook application
                   Outlook outlookApplication = new Outlook();
  
                   // Get the Outbox folder
                   OutlookFolder outbox = outlookApplication.getDefaultFolder(FolderType.OUTBOX);
  
                   // Create a new mail in the outbox folder
                   OutlookMail mail = (OutlookMail) outbox.createItem(ItemType.MAIL);
  
                   // Set the subject, destination and contents of the mail
                   mail.setSubject("Hello world !");
                   mail.setTo("me@test.com");
                   mail.setBody("This is a test message.");
  
                   // Send the mail
                   mail.send();
  
                   // Dispose the library
                   outlookApplication.dispose();
                }
                catch(ComponentObjectModelException ex)
                {
                   System.out.println("COM error has occured: ");
                   ex.printStackTrace();
                }
                catch(LibraryNotFoundException ex)
                {
                   // If this error occurs, verify the file 'moyocore.dll' is present
                   // in java.library.path
                   System.out.println("The Java Outlook Library has not been found.");
                   ex.printStackTrace();
  
  
  
      }
  }
  </code></pre>
  
  <p>Below is the error
  javax.faces.el.EvaluationException: //C:/Users/Darwish/AppData/Roaming/JDeveloper/system11.1.2.4.39.64.36.1/o.j2ee/drs/New/Project1WebApp.war/fields.jsf @9,70 action="#{TheBean.testbutton_action}": java.lang.NoClassDefFoundError: com/moyosoft/connector/com/ComponentObjectModelException
      at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:51)
      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
      at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:787)
      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1252)
      at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:973)
      at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:354)
      at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:202)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:508)
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
      at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
      at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:125)
      at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
      at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
      at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
      at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:293)
      at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:199)
      at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:173)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
      at java.security.AccessController.doPrivileged(Native Method)
      at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
      at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
      at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
      at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
      at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
      at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
      at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
      at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
      at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
  Caused by: java.lang.NoClassDefFoundError: com/moyosoft/connector/com/ComponentObjectModelException
      at project1.TheBeanC.testbutton_action(TheBeanC.java:67)
      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(Unknown Source)
      at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
      at org.apache.myfaces.trinidad.component.MethodExpressionMethodBinding.invoke(MethodExpressionMethodBinding.java:46)
      ... 44 more
  Caused by: java.lang.ClassNotFoundException: com.moyosoft.connector.com.ComponentObjectModelException
      at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
      at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
      at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:64)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:305)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:246)
      at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:179)
      at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:43)
      ... 53 more</p>