cancel
Showing results for 
Search instead for 
Did you mean: 

Stand alone client accessing JavaMail

Former Member
0 Kudos

I have a stand alone batch processing java application that uses the mail.jar and activation.jar to send out notification emails. I was using Netweaver as my jms provider but was wondering if it is possible to remotely access any java mail functionality? If so, can you provide me with a code example on how to do it. Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

former_member185706
Participant
0 Kudos

Hi Michael,

there is javamail service in J2EE engine. It provides mail client features to the components running on the engine. As J2EE specification requests, here is a java:comp/env/mail/MailSession object bound to engine's naming envirnonment, which can be lookup.

For standalone modules, outside the engine it can be used too, but i think it is useless because it will be the same functionality like using standalone jars.

You can refer to the javamail examples, that comes with the engine.

Here you can find some helpful links :

http://help.sap.com/saphelp_nw04/helpdata/en/0c/e5b2dd9efa964d919959e04c2811d0/frameset.htm

http://help.sap.com/saphelp_erp2005/helpdata/en/1a/ebd9549559df4a826df86b66e4e753/frameset.htm

http://help.sap.com/saphelp_erp2005/helpdata/en/2e/c00e408230c442e10000000a1550b0/frameset.htm

I hope this helps you.

Regards

Bojidar

Former Member
0 Kudos

Bojidar,

I should let you know what I am trying to do. I have a stand alone java application. This application has some unique functionality and we do not want to put it inside of netweaver. We run this java application on a large number of blade servers (min of 40), and we do not want to install netweaver on each server. We have been tasked to remove all open source and to leavage everything we can of netweaver. We have switched over JMS, DB Connection Pooling, and the last piece is our e mail notification. I am sort of new to java. I orginally wrote the stand alone e mail stuff using the mail.jar and activation.jar (there are numerous examples on the web). What I want to do is remove my dependencies on these 2 jars and utilize netweaver to do the emailing. Any ideas on how to do that? Thanks again for your help!

Mike

Former Member
0 Kudos

Hi

You can get all j2ee and sap related j2ee jars in ..\usr\sap\J2E\JC00\j2ee\j2eeclient folder . Alll these jars are used for accessing SAP Web As j2ee components from stand alone clients.

Hope this helps , please mark points for helpful answers .

regards

rajeshkr

Former Member
0 Kudos

Hi

There is a java mail tutorial which might give soem insight on how to implement Java Mail using SAP web AS

http://help.sap.com/saphelp_nw04/helpdata/en/2e/c00e408230c442e10000000a1550b0/content.htm

Hope this helps , please mark helpful answers

regards

rajeshkr

former_member185706
Participant
0 Kudos

Hi Mike,

if you whant to remove references to the exteral jars, you have to deploy your standalone application on the J2EE server(as i understood that it runs separately).

If you make it as J2EE engine application, you can use directly functionality provided by Javamail service provider, and you should not explicitly set references to mail and activation libraries.

You can have a look at the javamail examples, supplied by the engine. It is a small application that implements sending and reading e-mail boxes for all supporting protocols - SMTP, POP3, IMAP, NNTP. You can find the source code of this application in its directory (like ..\server0\apps\sap.com\com.sap.engine.docs.examples\servlet_jsp\_default\root\examples\javamail\src.zip).

I assume that in your standalone application , there is a code simliar to :


Properties props = new Properties();
props.put(name, value);
props.put (...)
Session sess = Session.getDefaultInstance(props);
MimeMessage msg = new MimeMessage(sess);
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO, to);
msg.setSubject(subject);
msg.set....
...
Transport tr = sess.getTransport("smtp");
tr.connect(host, user, password);
tr.sendMessage(msg);
....

So i think if you simply put your code in the servlet or JSP file, you can realise the same functionality as in your standalone application.

I hope this helps you

Regards

Bojidar

Former Member
0 Kudos

Another stupid new java guy question. Can you run applications (one with a main method) inside a J2EE server? If so, how do you do that?

As far as the java mail code goes, I pretty much understand that part. I basically have the same as your code example.

Former Member
0 Kudos

Hi Micheal

Can you be more specific as to why are u looking for this strange req?

As far as main method is concerned it will act like any normal method . But if you are thnkng of invoking it as a stand alone java program (command prompt) then this cnt be done in Web AS , can you please tell me your requirement

As far as my know how goes JMX can be used for this , but i had used it in Jboss , not on sap web as

Hope this helps , please mark points for helpful answers

regards

rajesh kr

former_member185706
Participant
0 Kudos

Michael,

you can run this in separate thread - you should convert your application to implement java.lang.Runnable.

But i don't like this ...

So if you can give me much more info about the functionality of your standalone application and its purpose, i can try to suggest more elegant and J2EE compatible solution

Regards

Bojidar

Answers (1)

Answers (1)

Former Member
0 Kudos

Java mail api is generally used as local set of classes. Iam afriad if it has remote functionlities of ejbs. If you want it to be used remotely, use a session bean to invoke the mail apis

Sujesh

Former Member
0 Kudos

I was afraid of that. Thanks for the info.