on 03-31-2008 8:33 AM
I want to send mail through front end by using Adobe Form. The adobe form must be mailed as an attachment to the email. The adobe form is not saved anywhere. It is displayed to the user and the used will mail it by using the email button, to which the code written below is used. But the applicatin is not sending mails and the code is not accepting the attachment. It is displaying an error message "Sending failed; nested exception is: javax.mail.MessagingException: IOException while sending message; nested exception is: java.io.FileNotFoundException: ./temp/webdynpro/web/local/LifeCycleLetters/Components/com.lifecyclelettersapplication.LifeCycleLettersComponent/test.pdf (No such file or directory) "
The message is not displayed when the attachment code is commented and even the mail in not sent plz suggest something.
public void onActionSend(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionSend(ServerEvent)
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
{
MimeMultipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
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 this will be the attachment
messageBodyPart = new MimeBodyPart();
// Code for adding attachment
messageBodyPart = new MimeBodyPart();
messageBodyPart.setDataHandler(
new DataHandler(
new MemoryDataSource(
wdContext.currentContextElement().getPdfsource())));
messageBodyPart.setFileName(
wdContext.currentContextElement().getAttachmentName());
messageBodyPart.setHeader("Content-Type", "application/pdf");
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
String filename = "temp
webdynpro
web
local
LifeCycleLetters
Components
com.lifecyclelettersapplication.LifeCycleLettersApplication
LifeCycle.pdf";
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();
}
Commented For Testing By Umang//
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();
}
catch(Exception e)
{
wdContext.currentContextElement().setTeststatus("action send"+e.getMessage());
}
//
//@@end
}
Sent mail through backend
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi...
Could you please check whether the PDF u have created is there in ur Directory as an xdp file?
Regards
Mustafa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.