cancel
Showing results for 
Search instead for 
Did you mean: 

Send mail inside JSPDynpage

Former Member
0 Kudos

Hi everyone:

I need to send a mail inside a Portal application, using the user logged email and send to other portal user. I need to know any solutions, because is very urgent, I was testing with Transport.send(msgMail); with this libraries:

but nothing happened, neither throws an error message.

this is the code:

try{

Properties props = System.getProperties();

props.put("mail.smtp.host", "x.x.x.x"); //host ip

props.put("mail.smtp.auth", "true");

Session session = Session.getInstance(props);

MimeMessage message = new MimeMessage(session);

message.setFrom(

new InternetAddress("user1@mail.cl"));

message.addRecipient(

Message.RecipientType.TO,

new InternetAddress("user2@mail.cl"));

message.setSubject("Hello JavaMail Attachment");

MimeBodyPart messageBodyPart = new MimeBodyPart();

messageBodyPart.setText("This is a test");

Transport.send( message );

}catch(Exception ex){

myBean.setError(ex.getMessage());

}

I'm trying with IMailItem, ISendTransport..... but I need help with the implementation.... (Collaboration apis) Because I have problems to obtain the IGroupwareManager.

Help! please. is very urgent

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Leslie,

i am using this code, which looks almost exactly like yours one and it works perfectly fine.

There is a slight difference in calling <i>Session.getInstance()</i> method and you didn't set the message body (there is no <i>message.setText</i> in your code), but not sure it could be the mistake.

Just for checking:


		try{
			Properties props = System.getProperties();

			// Setup mail server
			props.put("mail.smtp.host", "YOUR SMTP HOST");

			// Get session
			Session session = 
			  Session.getDefaultInstance(props, null);

			// Define message
			MimeMessage message = new MimeMessage(session);
			message.setFrom(new InternetAddress("Address from"));
			message.addRecipient(Message.RecipientType.TO,new InternetAddress("Address to"));
		
			//FIll in
			message.setSubject("Subject");
			message.setText("Mail Body");

			// Send message
			Transport.send(message);
		}catch(MessagingException e){
			//... Handling exception
		}

And, are you sure, it doesn't jump to CATCH block?

regards.

mz

Answers (1)

Answers (1)

Former Member
0 Kudos

Thanks Maxim!

you resolved my problem, now is working very good.

I gave you 10 points.... I don't know if I did it well.(problem solved 10 *)