cancel
Showing results for 
Search instead for 
Did you mean: 

Upload File to send via e-mail

former_member1098367
Participant
0 Kudos

Hi all,

I need to upload a file via webdynpro java to send to an e-mail.

I'm using Netweaver 04 web dynpro Java. In 04s we have a type IWDResource, but in this version, we

don't have this type

I'd defined a resource file (type binary), a file name (type string) in content.

my problem is how can I get the URL of the file that I'm uploading, to send via e-mail?

thank you

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member192434
Active Contributor
0 Kudos

Hi

try this

wdContext.currentContextElement().getResourceURL();

thanks

AB

former_member1098367
Participant
0 Kudos

Hi,

thanks for your reply,

how can I define this wdContext.currentContextElement().getResourceURL(); In which proprety of FileUpload I have to set up this value?

Br

Joã

Former Member
0 Kudos

You need a type com.sap.ide.webdynpro.uielementdefinitions.Resource attribute for propertie Resource and then:

InputStream input = wdContext.currentXXXelement().getResource().read(false);

and you can send it like an attachment using java mail or EJB Mail:

props = new Properties();

initialContext = new InitialContext(props);

session = (Session) initialContext.lookup("java:comp/env/mail/MailSession");

mailSession = Session.getInstance(session.getProperties(), null);

transport = mailSession.getTransport("smtp");

transport.connect();

/* build the email */

transport.sendMessage(msg, to);

former_member1098367
Participant
0 Kudos

Hi,

Thanks for your reply,

I'm using Netweaver 2004. The IWDResource is only available since Netweacer 2004s.

Br

Joao

Former Member
0 Kudos

If you read wdContext.currentXXXElement().getData(), what happens? Do you obtain a byte[]? In that case you can use ByteArrayInputStream to read it.