Mailapi.jar not working correctly
Posted: Fri Jun 12, 2015 9:42 pm
Hello,
I have a custom Author Action implemented in a AuthorOperation Java class. I need it to send an email. I wrote the following class to send an email
However, when I debug my code from Eclipse in oxygen, once I reach the Transport.send() function, I always get this error:
I understand that this class needs to be apart of my class path etc, but seeing as it is a library loaded by oxygen, I would assume there is no extra work for me to do. In my C# code I use the same mailbox to send SMTP email with no user name or authorization. Any help would be greatly appreciated.
Thanks,
Dirk
I have a custom Author Action implemented in a AuthorOperation Java class. I need it to send an email. I wrote the following class to send an email
Code: Select all
public class SendEmail {
public static void send(String data){
// Recipient's email ID needs to be mentioned.
String to = "ddubois1@matrox.com";
// Sender's email ID needs to be mentioned
String from = "techwriting@matrox.com";
// Assuming you are sending email from localhost
String host = "mailbox.matrox.com";
// Get system properties
Properties properties = System.getProperties();
// Setup mail server
properties.put("mail.smtp.host", host);
// Get the default Session object.
Session session = Session.getInstance(properties, null);
try{
// Create a default MimeMessage object.
MimeMessage message = new MimeMessage(session);
// Set From: header field of the header.
message.setFrom(new InternetAddress(from));
// Set To: header field of the header.
message.addRecipient(Message.RecipientType.TO,
new InternetAddress(to));
// Set Subject: header field
message.setSubject("This is the Subject Line!");
// Now set the actual message
message.setText(data);
// Send message
Transport.send(message);
}catch (MessagingException mex) {
mex.printStackTrace();
}
}
}
Code: Select all
javax.mail.NoSuchProviderException: smtp
at javax.mail.Session.getService(Session.java:775)
at javax.mail.Session.getTransport(Session.java:713)
at javax.mail.Session.getTransport(Session.java:656)
at javax.mail.Session.getTransport(Session.java:636)
at javax.mail.Session.getTransport(Session.java:691)
at javax.mail.Transport.send0(Transport.java:188)
at javax.mail.Transport.send(Transport.java:120)
at com.matrox.mil.SendEmail.send(SendEmail.java:45)
at com.matrox.mil.VisualSourceSafe.checkInFile(VisualSourceSafe.java:71)
at com.matrox.mil.CheckInVSS.doOperation(CheckInVSS.java:28)
at ro.sync.ecss.extensions.h.k(Unknown Source)
at ro.sync.ecss.extensions.h.performAction(Unknown Source)
at ro.sync.ecss.extensions.k.gzc(Unknown Source)
at ro.sync.ui.application.d.m.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at com.jidesoft.plaf.vsnet.VsnetMenuItemUI.doClick(Unknown Source)
at com.jidesoft.plaf.vsnet.VsnetMenuItemUI$MouseInputHandler.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Thanks,
Dirk