Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


[java] Email from Java applet/application???

This topic is 5920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, Im working on a game Im going to release soon and I was wondering if any one knew of a way to send email from an application or applet? I''m not looking for anything too terribly involved but anything you guys know about would be much appreciated. Thanks in advance!

Share this post

Link to post
Share on other sites
Well, there''s JavaMail. You can use it from an application. For an applet, send the email data to a servlet on the server, and have it send it through JavaMail.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
The first time I did this was right back when JMail was in EA so I used the following work around (Note I ripped this from old code and it won''t work as a straight copy/paste job). The basic premise is to create a mailto: url and post the mail via that programaticaly.
As follows:

URL u = new URL("mailto:" + To.getText());
URLConnection c = u.openConnection();
out = new PrintWriter(new OutputStreamWriter(c.getOutputStream()));
out.println("From:" + From.getText());
out.println("To:" + To.getText());
out.println("Subject:" + Subject.getText());
}catch(Exception e){e.printStackTrace();}

Share this post

Link to post
Share on other sites
All right guys, thanks for your help. I found a different solution though that works for what I need to do. Here it is:

try {
Runtime.getRuntime ().exec ("rundll32.exe url.dll,
FileProtocolHandler mailto:joe@anywhere.com");
catch (Exception exception) {}

Basically it just loads the dll that is used to run commands and the dll to parse url strings. After that it will load whichever mail client the user has set as default (Outlook, etc..) and after that its up to it. Pretty neat huh?
This just works for Windows, but I''m sure there are other similar calls for other OS''s.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!