Como enviar e-mail com tags html

2 respostas
fmduque

Estou tentando enviar um e-mail com algumas tags html, mais não estou conseguindo. Alguem sabe me dizer oque tem de errado ou faltando no codigo abaixo?

msg.setSubject("Mensagem com html");

String mailer = "sendhtml";
StringBuffer sb = new StringBuffer();

sb.append("<HTML>
");
sb.append("<HEAD>
");
sb.append("<TITLE>
");
sb.append("</TITLE>
");
sb.append("</HEAD>
");

sb.append("<BODY>
");
sb.append("<H1>Teste</H1>" + "
");

sb.append("</BODY>
");
sb.append("</HTML>
");

msg.setDataHandler(new DataHandler(new ByteArrayDataSource(sb.toString(), "text/html")));

msg.setHeader("X-Mailer", mailer);
Transport.send(msg);

Quando abro a pagina o tomcat não reconhece o ByteArrayDataSource.

2 Respostas

Rafael_Steil

Veja se isso ajuda:

http://www.guj.com.br/forum/viewtopic.php?t=132&highlight=javamail+html

Rafael

fmduque

E como ajuda… valeu Rafael.
Fiz uma busca antes de postar, mais naum tinha visto esse tópico.

Valeu!

Criado 26 de fevereiro de 2004
Ultima resposta 27 de fev. de 2004
Respostas 2
Participantes 2