Skip to Content
author's profile photo Former Member
Former Member

cannot send email from WD Java

hi Experts,

I have created an email WD Java Application, this application sends an email to the users on click of a button.

My Problem is this application runs well on SP11, but we have upgraded our dev portal to SP14.

On SP14 mail is not send. Please help its really very urgent.

I am pasting the code used for sending email.

wdContext.currentEmailElement().setFrom(wdContext.currentContextElement().getEmpMailID());
	  wdContext.currentEmailElement().setCc("");
	  wdContext.currentEmailElement().setBcc("");
	  wdContext.currentEmailElement().setSubject("Personal Travel Request.");
	  wdContext.currentEmailElement().setTo("corporatetravel.booking@zmail.ril.com");
	
	  Properties props = new Properties();
	  String host = "rmail070.zmail.ril.com";
	  props.put("rmail070.zmail.ril.com", host);
	  Session session = Session.getInstance(props, null);
	  MimeMessage message = new MimeMessage(session);
	  Address toAddress = new InternetAddress();
	  Address fromAddress = new InternetAddress();
	  Address ccAddress = new InternetAddress();
	  Address bccAddress = new InternetAddress();
	  try
	  {
	  /* Creates an email object with different parts, one for the
	  text and another for the attached file */
	  MimeMultipart multipart = new MimeMultipart();
	  BodyPart messageBodyPart = new MimeBodyPart();
	  /* the following statements build up the email */
	  if (! wdContext.currentEmailElement().getFrom().equals(""))
	  {
	  fromAddress = new InternetAddress(wdContext.currentEmailElement().getFrom());
	  message.setFrom(fromAddress);
	  } if (! wdContext.currentEmailElement().getTo().equals(""))
	  {
	  toAddress = new InternetAddress(wdContext.currentEmailElement().getTo());
	  message.setRecipient(Message.RecipientType.TO,toAddress);
	  }
	  if (! wdContext.currentEmailElement().getCc().equals(""))
	  {
	  ccAddress = new InternetAddress(wdContext.currentEmailElement().getCc());
	  message.setRecipient(Message.RecipientType.CC,ccAddress);
	  }
	  if (! wdContext.currentEmailElement().getBcc().equals(""))
	  {
	  bccAddress = new InternetAddress(wdContext.currentEmailElement().getBcc());
	  message.setRecipient(Message.RecipientType.BCC,bccAddress);
	  }
	  if (!wdContext.currentEmailElement().getSubject().equals(""))
	  {
	  message.setSubject(wdContext.currentEmailElement().getSubject());
	  }
	  if (! wdContext.currentEmailElement().getBody().equals(""))
	  {
	  messageBodyPart.setText(wdContext.currentEmailElement().getBody());
	  }
	
	  multipart.addBodyPart(messageBodyPart);
	  
		  /* a new part will be added, in the complete email this will
		  be the attachment */
		  
		  messageBodyPart = new MimeBodyPart();
//		  try{
	
//		  String filename =WDURLGenerator.getResourcePath(wdComponentAPI.getDeployableObjectPart(),"test.pdf");
//		  DataSource source = new FileDataSource(filename);
//		  messageBodyPart.setDataHandler(new DataHandler(source));
//		  messageBodyPart.setFileName(source.getName());
//		  messageBodyPart.setHeader("Content-Type","application/pdf");
//		  multipart.addBodyPart(messageBodyPart);
		  message.setContent(multipart);
		  Transport.send(message);
//		  }
//		  catch(WDAliasResolvingException e)
//				  {
//					 e.getMessage();
//				  }
	
		  }

		  catch (AddressException e)
		  {
		  wdComponentAPI.getMessageManager().reportWarning(e.
		  getLocalizedMessage());
		  e.printStackTrace();
		  }
		  catch (SendFailedException e)
		  {
		  wdComponentAPI.getMessageManager().reportWarning(e.getLocalizedMessage());
		  e.printStackTrace();
		  }
		  catch (MessagingException e)
		  {
		  wdComponentAPI.getMessageManager().reportWarning(e.getLocalizedMessage());
		  e.printStackTrace();
		  }

Points will be rewarded to helpful answers.

Regards,

Sanjyoti.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Mar 29, 2008 at 08:49 AM
    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi,

      I want to add one more info. The document from which i got the code states that one of the "Prerequisites" is SP 11 here it is not specified that it will work above SP11.

      Please help.

      Regards,

      Sanjyoti.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.