on 06-17-2007 2:13 PM
Hi all,
I am trying to send a KM document as email attachment with the following peice of code. But I am getting FileNotFoundExceptio. Can anyone guide me as to where its going wrong. Any help will be appreciated.
String filePath = "";
ResourceContext ctx = new ResourceContext(getEP5User());
RID rid = RID.getRID("/documents/LRForms/0000000054.pdf");
IResource pdfResource =ResourceFactory.getInstance().getResource(rid, ctx);
filePath =
"irj\servlet\prt\portal\prtroot\com.sap.km.cm.docs\"
+ pdfResource.getRID().toString();
Properties props = new Properties();
props.put("mail.smtp.host", host);
Session session = Session.getInstance(props, null);
MimeMessage message = new MimeMessage(session);
Address toAddress;
Address fromAddress;
Address ccAddress;
Address bccAddress = new InternetAddress();
MimeMultipart multipart = new MimeMultipart();
BodyPart messageBodyPart = new MimeBodyPart();
fromAddress = new InternetAddress("someone@domain.com");
message.setFrom(fromAddress);
toAddress = new InternetAddress("againsomeone@domain.com");
message.setRecipient(Message.RecipientType.TO, toAddress);
message.setSubject("Subject");
messageBodyPart.setText("Please find attached the details.");
multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filePath);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(source.getName());
messageBodyPart.setHeader("Content-Type", "application/pdf");
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
Transport.send(message);
On executing this code I am getting following exception.
MessagingException javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.MessagingException: IOException while sending message; nested exception is: java.io.FileNotFoundException
Thanks and regards,
Jaydeep
Hi,
The file path for the document will be like this
/irj/go/km/docs/documents/LRForms/0000000054.pdf
Regards,
Beevin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Did you check permissions/security zone settings on the folder/file?
Can you access the file directly from the browser?
Regards,
Omri
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 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.