cancel
Showing results for 
Search instead for 
Did you mean: 

Sending Adobe Interactive Forms via Email

Former Member
0 Kudos

Hi,

I have an application displaying the pdf within web dynpro. I would like to add a button that will send the pdf displayed via email.

My question is do I have to save the pdf first in a directory within the server?

Any idea on what is the best approach for this?

Thanks in advance,

Iwan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Yes u can send email to the id which u want.There is a option for creating an email button in interactive forms.Create an email button and change the properties of the button to the id that u want.

u can directly send the form without saving it.<b>But for ur information this email option will send ur pdf in the xml format with the values that u give in the pdf input</b>.U can also send it by saving it.Then this becomes ur offline form.

If u want to send it as a pdf one then it is best to have a button and then write ur java mail code inside the action of it,which might help u in doing this.

Hope this helps u,

Regards,

Nagarajan.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Henrik,

This is what I am looking for. Just one follow up how I can add the class to the project, but do you know how to make other project to use this class?

Thanks again.

Message was edited by: Iwan Santoso

Former Member
0 Kudos

Hi,

I'm sorry you misunderstood what i need. The way you described it, is done manually.

Imagine the view in web dypro has Adobe form displayed, below the form there is a button to send the adobe form as an attachement via email and input field as the email address.

I would like the user just type in the email address and click the send button in order to send the form via email. And the email will have a predifined text body and the displayed pdf as attachement.

This can be done 'manually' as you have described, but I want to do it programmatically. Do you have any idea?

Regards,

Iwan

markus_meisl
Active Contributor
0 Kudos

Hi Iwan,

it would probably work best if you program your Web Dynpro application in such a way that when a user enters the e-mail address and clicks on Send, the action triggered by this accesses the same Context node ('pdfSource') as the one you use to display the PDF in the browser.

The displayed PDF is not persisted anywhere, so it might be complex to actually send this physical PDF instead of one generated by the server (possibly generated again in a second step).

It all depends on your scenario: Does the user always have to look at the form before sending it? Does he enter anything in the generated form before sending it? Does he always send it? You need to know in detail what your process looks like before working with the form.

Kind regards,

Markus Meisl

SAP NetWeaver Product Management

Former Member
0 Kudos

Hi Markus,

Thanks for the response. The scenario that I have is to generate the form dynamically. For example the screen has several input fields and based on this input fields will determine how the final pdf looks like. I don't need to send the 'displayed' pdf. I should say I would like to send pdf that is generated at run time.

I am under the assumptiopn that pdfSource contains the source of PDF in binary mode... like when doing sapscript and smartform you can have it as OTF format and covert it to pdf format. In ABAP I send the 'binary' pdf format as an attachment. I would like to do the same.

To re-phrase my question: How can I send the pdfSource as an pdf attachment?

Thanks,

Iwan

markus_meisl
Active Contributor
0 Kudos

Hi Iwan

have you had a look at the e-mail tutorial for Interactive Forms on the Web Dynpro tutorial page?

http://sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/49f2ea90-0201-0010-ce8e-de18b94aee2d -> Using PDF forms -> Java Mail API

Regards,

Markus

Former Member
0 Kudos

Hi Marcus,

I did see that tutorial. I stump on the following code:

String filename =

"temp
webdynpro
web
local
TutWD_EmailInteractiveForm_Init
Components
com.sap.tut.wd.emailinteractiveform.EmailInteractiveFormComp
TravelRequest.pdf";

DataSource source = new FileDataSource(filename);

As you can see, the filename is assigned and for this to work correctly, the file should already be saved to that location. Is it possible if the pdf file is generated dynamically. I assume that the pdf file is stored in pdfSource of the context. However I got byte[] is incompatible with DataSource when I am trying to use pdfSource. Any idea?

HenrikD
Participant
0 Kudos

Hi,

I had the same challenge some time ago. I managed to avoid using a physical file by using a Class. It might not be the only solution, but it did the job

messageBodyPart = new MimeBodyPart();

<b>messageBodyPart.setDataHandler(
	new DataHandler(
		new MemoryDataSource(
			wdContext.currentContextElement().getPdfSource())));</b>

messageBodyPart.setFileName(
	wdContext.currentContextElement().getAttachmentName());

messageBodyPart.setHeader("Content-Type", "application/pdf");

multipart.addBodyPart(messageBodyPart);

message.setContent(multipart);

public class MemoryDataSource implements DataSource {
	private byte[] data;
	private String filename;

	public MemoryDataSource(byte[] data) {
		this.data = data;
	}
	public String getContentType() {
		return "application/pdf";
	}
	public InputStream getInputStream() throws IOException {
			return new ByteArrayInputStream(data);
	}
	public void setName(String name) {
		this.filename = name;
	}
	public String getName() {
		return this.filename;
	}
	public OutputStream getOutputStream() throws IOException {
		return null;
	}
}

Best regards,

Henrik

Former Member
0 Kudos

Hello markus, is this possible to use WD for ABAP to send pdf in mail ? Please let me know for any possible examples.

Thanks

Prasad

Former Member
0 Kudos

Hi Prasad,

It is possible in WDA. You can check for the ABAP code in Jeff Gebo's webinar availabein SDN.. Any queries, do update , i shall try to solve it :).

Thanks and Regards,

Anto.

Former Member
0 Kudos

Hi Henrik,

i try to implement your code inside but i still have error on this following fields

<b>messageBodyPart.setDataHandler(new DataHandler(new MemoryDataSource(wdContext.currentContextElement().getPdfSource())));</b>

the error it give me is this

The constructor DataHandler(MemoryDataSource) is undefined

i try to create the java class as what u type

package com.sap.example.uploademail;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * @author Admin
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class MemoryDataSource {
	private byte[] data;
		private String filename;
 
		public MemoryDataSource(byte[] data) {
			this.data = data;
		}
		public String getContentType() {
			return "application/pdf";
		}
		public InputStream getInputStream() throws IOException {
				return new ByteArrayInputStream(data);
		}
		public void setName(String name) {
			this.filename = name;
		}
		public String getName() {
			return this.filename;
		}
		public OutputStream getOutputStream() throws IOException {
			return null;
		}
}

wonder which part i do wrong?

Former Member
0 Kudos

Hi all,

I have done the same thing but now I need send it without viewing the pdf document in background .I tried making the interactive form element invisible (none or blank).But then it gives me an error as null pointer exception (as the pdfsource becomes null so data is null )

could any body help me for the same.

Regards

Sheetal

Former Member
0 Kudos

Hi,

I have created adobe interactive form for an offline scenario. I looking for the upload functionality.

I am able to view the xml of the form data. But when i trigger the useraction to view the form, it throws a dump.

I have mapped the pdf source and data source to the pdf source and data_nodes properly.But i m not sure what needs to be filled in the template source, can you please gimme some pointer on this,as i didnt find this example in wd abap in sdn.

I find most of the examples are on wd java.. and i find abit different in wd abap.

Thanks,

Saujanya

Former Member
0 Kudos

Hi Henrik,

I am also facing an error :

the constructor DataHandler(MemoryDataSource) is undefined

Please let me the what should be done ?

Former Member
0 Kudos

Hi Nagarajan,

Thanks. I'm a newbie, can you elaborate more on how to save the pdf in the server? i certainly do not want to save pdf at user pc before sending the email. I knew how to send email from java mail. I just need more explanation on how to save the pdf in the server and then attach it to the email.

Thanks,

Iwan

Former Member
0 Kudos

Hi Iwan,

Sorry for the late reply.

Saving the pdf form in pc is very simple.If u run ur interactive forms,in the form u will have the save option (save a copy).Just by clicking on that u can save ur pdf in the local machine.

But in order to send this form as an email then u have to again upload it in ur application and then only u can send it through mail.For this u have to create an upload element in the WD application and then u could do it easily.

Hope this helps u,

Regards,

Nagarajan.