Estou tentando enviar um e-mail a partir de um servlet.
Conforme descrito abaixo:
[code]Properties p = new Properties();
p.put(“mail.host”, “smtp2.locaweb.com.br”);
Session session = Session.getInstance(p, null);
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(“senhas@divecenter.com.br”));
msg.setRecipient(Message.RecipientType.TO, new InternetAddress(augusto@divecenter.com.br));
msg.setSubject(“Senha de acesso ao Site Dive Center”);
O código está funcionando, porém, o email recebido só tem a linha “yyyyyyy”. A minha intenção era que aparecesse a linha xxxxxxxxx, uma linha em branco e depois a linha yyyyyyyy.
Resumindo, não sei como saltar de linha, alguém pode me ajudar?
Convenience method that sets the given String as this part’s content, with a MIME type of “text/plain” and the specified charset.
The given Unicode string will be charset-encoded using the specified charset. The charset is also used to set the “charset” parameter.
void setText ( String text ) throws MessagingException
Convenience method that sets the given String as this part’s content, with a MIME type of “text/plain”.
If the string contains non US-ASCII characters. it will be encoded using the platform’s default charset. The charset is also used to set the “charset” parameter.
Note that there may be a performance penalty if text is large, since this method may have to scan all the characters to determine what charset to use.
If the charset is already known, use the setText method that takes the charset parameter.
Estou executando o mesmo codigo citado acima, porem, um erro me é retornado!
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: javax.activation.DataSource
at Agricola.Email.jButton1_actionPerformed(Email.java:59)
at Agricola.Email.mav$jButton1_actionPerformed(Email.java)
at Agricola.Email$1.actionPerformed(Email.java:42)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:158)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)