on 04-19-2007 1:00 AM
Hi All,
I have developed online interactive form app(dynamic).
When user clicks the submit button after entered the data,
I want to email the PDF form as an attachment to some users.
Could anyone please explain the steps or give me some sample code?
Thanks
Sundar
Hi All,
I hope the following approach will solve all your problem.
For sending the PDF file filled by the User to an email address as an attachment
a. Create a Button
b. Choose control type as Submit
c. Go to Submit Tab and select Submit field as PDF
d. In the URL field mention - mailto : email address (for example mailto : workflow@test.com)
Thanks
Satya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I found this in one of the forums dont remember which, here is the code
public boolean EmailForm( java.lang.String pernr, java.lang.String toEmail, java.lang.String fromEmail )
{
//@@begin EmailForm()
boolean flag = true;
try {
String host = "exchangerelay.yourserver.com";
// Get system properties
Properties props = System.getProperties();
// Setup mail server
props.put("mail.smtp.host", host);
// Get session
Session session = Session.getDefaultInstance (props, null);
// Define message
MimeMessage message = new MimeMessage(session);
byte[] b = wdContext.currentContextElement().getPdfSource();
//Attachment
ByteArrayInputStream ba = new ByteArrayInputStream(b);
String filename ="Filename.pdf";
//This will create a file on the server under folder "server0"
File file = new File(filename);
FileOutputStream fos = new FileOutputStream(file);
int i = 0;
for (i = 0; i < b.length; i++) {
fos.write(b<i>);
}
fos.close();
DataSource source = new FileDataSource(file);
BodyPart messageBodyPart = new MimeBodyPart();
message.setFrom(new InternetAddress(fromEmail));
message.addRecipient(
Message.RecipientType.TO,
new InternetAddress(toEmail));
message.setSubject ("Subject : ");
message.setText(
"This is a confirmation receipt.");
Multipart multipart = new MimeMultipart();
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setHeader("Content-Type", "application/pdf");
messageBodyPart.setFileName(filename);
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
Transport transport = session.getTransport("smtp");
transport.connect(host, "username", "password");
transport.sendMessage(message, message.getAllRecipients());
transport.close();
flag = true;
//delete file if you want to here
file.delete();
} catch (FileNotFoundException e) {
flag = false;
wdComponentAPI.getMessageManager().reportException(
"FileNotFoundException : " + e.getMessage(),
false);
} catch (IOException e) {
flag = false;
wdComponentAPI.getMessageManager ().reportException(
"IOException : " + e.getMessage(),
false);
} catch (MessagingException e) {
flag = false;
wdComponentAPI.getMessageManager().reportException(
"MessagingException : " + e.getMessage(),
false);
}
return flag;
//@@end
}
thanks,
Sanketh
Hi Sundar,
for sending email you can use the javascript below. Use the Button from the group Standard and move javascript to click event.
var myDoc = event.target;
try {
myDoc.mailDoc({
bUI: false,
cTo: "email@aa.com",
cCC: "",
cSubject: "Subject",
cMsg: ""
});
} catch (e) {}
Regards
Michal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sundar,
I think this link should be useful to you.
Just play around with this exercise,am sure you will get some breakthrough.
Regards
<b><i>Raja Sekhar</i></b>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.