Skip to Content
0
Former Member
Feb 12, 2008 at 12:03 PM

Issue in sending mail from webdynpro application

7 Views

Error :

javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.MessagingException: Unknown SMTP host: mail.yochanatech.com ; nested exception is: java.net.UnknownHostException: mail.yochanatech.com

In visual administrator

SMTP hostname : mail.yochantech.com

this my code ;


	String host ="mail.yochanatech.com "; // Specify the host
//	   Get the From Address
//	String from = wdContext.currentContextElement().getFromAddress();
	String from ="arjun@yochanatech.com";
//	   Get the To Address
//	String to = wdContext.currentContextElement().getToAddress();
	String to="arjun@yochanatech.com";
//	   Initialize Session
	Properties props = System.getProperties();
	props.put("mail.smtp.host", host);
	
	Session session = Session.getDefaultInstance(props, null);
//	   Create new MimeMessage
	MimeMessage message = new MimeMessage(session);
	IWDMessageManager messageMgr = wdControllerAPI.getComponent().getMessageManager();
	try {
 // Set the From Address
		message.setFrom(new InternetAddress(from));
//		   Set the To Address
		message.addRecipient(Message.RecipientType.TO,
		new InternetAddress(to));
//		   Set the Subject
		message.setSubject("Test Mail");
//		   Set the Text
//		message.setText(wdContext.currentContextElement().getTextMessage());
		message.setText("test mail trigered");
//		   Send message

               
		Transport.send(message);
			
		messageMgr.reportSuccess("Mail Sent Successfully");
		} catch (AddressException e) {
		messageMgr.reportException(e.toString(),false);
		} catch (MessagingException e) {
		messageMgr.reportException(e.toString(),false);
		}

when i debug the code

Transport.send(message);

it is not exceuting

Thxs

ARJUN.G