-1

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?

Below is my code and my error

Thank you

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();



    }
}

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

Darwish
  • 7
  • 6

3 Answers3

0

You can send emails using the "normal" method even if you only have intranet. Outlook is nothing fancy other than an User friendly interface for the email system. To be precise, you can send email using smtp protocal as long as you can connect to your mailing server even if it is intranet.

Steve
  • 11,696
  • 7
  • 43
  • 81
  • so i need to search how to send emails in java in general and i put the smtp protocol of my outlook server right? – Darwish Jan 20 '15 at 19:59
  • @Darwish yes just search how to send emails in java, for the smpt protocol part.... If you can send emails thru outlook then it means the email server is already setup. all you need is the IP address and receiving port of it. – Steve Jan 20 '15 at 20:02
  • i searched and i found a good code that meets my requirements, but i have 2 fields and are the username and password i need to provide them. the problem is that multiple users will be accessing my page and each user will have a different username and password. is there anyway to solve this issue. thanks alot for helping – Darwish Jan 21 '15 at 00:04
  • @Darwish you can either have them input them when they are sending the email or you can store them in the DB when they are registering. – Steve Jan 21 '15 at 00:13
  • isn't there is any way to get the username and password automatically without letting the user to enter credentials or refer to database? – Darwish Jan 21 '15 at 05:11
  • @Darwish i think i understand your question abit better now, you basically want the user to send emails thru the outlook account that he/she is currently logged into on his/her PC thru a browser – Steve Jan 21 '15 at 19:54
  • yes man it is true, i found a code i edited my question up but still i'm having an error – Darwish Jan 22 '15 at 22:11
  • @Darwish the problem is that, you probably dont have enough permission to do so inside a browser...unless you write a plugin for each browser you want to support. What you did is trying to send the email from serverside and that will use the server's credential to send the email not the user's – Steve Jan 22 '15 at 23:05
0

Outlook is a COM server which you can automate using the OLE COM technology. I don't use Java for developing, but I hope you will find how to call the COM servers in Java, for example - Is there OLE Automation in Java?. See Using Automation to Send a Microsoft Outlook Message. It shows you how to use Automation to create and send a Microsoft Outlook message.

Also you may find the How to automate Outlook from another program article helpful.

Community
  • 1
  • 1
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
0

i fount the answer

the problem was in the library path

i just needed to go to the library options in Jdeveloper and reselect the library in the JAR/Directory

Darwish
  • 7
  • 6