Javax.mail?

3 respostas
zerokelvin

Fala!
seguinte: envio o email, normal, mas só chega o anexo!
o que tá errado? já olhei na api e na net, esse setText funciona em outro código meu, com o mesmo objeto…

Authenticator auth = new SMTPAuthenticator();
    Session session = Session.getDefaultInstance(props, auth);

    session.setDebug(debug);

    // Criando a Mensagem
    Message msg = new MimeMessage(session);
	fileAttachment = "c:/backup.sql";
		 // create the message part 
   
	 MimeBodyPart messageBodyPart = new MimeBodyPart();
    
	 
	 //AQUI!
	 messageBodyPart.setText(statusMsg);

    source = new FileDataSource(fileAttachment);
	    
	 DH = new DataHandler(source);
	 messageBodyPart.setDataHandler(DH);
    messageBodyPart.setFileName(fileAttachment);
   
	 Multipart multipart = new MimeMultipart();
    multipart.addBodyPart(messageBodyPart);

	
	 

	
	
    // Configurando o from and para endereco
    InternetAddress addressFrom = new InternetAddress(from);
    msg.setFrom(addressFrom);

    InternetAddress[] addressTo = new InternetAddress[recipients.length];

    for (int i = 0; i < recipients.length; i++)

    {
        addressTo[i] = new InternetAddress(recipients[i]);
    }
    msg.setRecipients(Message.RecipientType.TO, addressTo);


    // Configurando o  Subject e o  Content Type
// Put parts in message
//    msg.setContent(multipart);
	 
	 msg.setText(statusMsg);
    msg.setSubject(subject);
    msg.setContent(multipart, "text/plain");
    Transport.send(msg);

3 Respostas

pedroroxd

tenta em vez do statusMsg colocar uma string normal, como “Teste”, e vê o que acontece…

zerokelvin

cara, mesma coisa…

zerokelvin

eita… resolvi aki
cada bodypart é uma parte hehehehehehee
então tem q criar um outro, setar o texto e depois adicionar ao multipart!
valeu pela ajuda

Criado 23 de abril de 2010
Ultima resposta 24 de abr. de 2010
Respostas 3
Participantes 2