Java code for opening the default email application
import java.awt.*;
import java.io.IOException;
import java.net.URI;
public class sendmail {
public static void main(String[] args)
{
Desktop d;
try
{
if (Desktop.isDesktopSupported() && (d = Desktop.getDesktop()).isSupported(Desktop.Action.MAIL))
{
URI msg = new URI("mailto:user@anything.com?subject=sending%20email");
d.mail(msg);
}
else
{
throw new RuntimeException("doesn't support this");
}
}
catch(Exception e)
{
}
}
}
import java.io.IOException;
import java.net.URI;
public class sendmail {
public static void main(String[] args)
{
Desktop d;
try
{
if (Desktop.isDesktopSupported() && (d = Desktop.getDesktop()).isSupported(Desktop.Action.MAIL))
{
URI msg = new URI("mailto:user@anything.com?subject=sending%20email");
d.mail(msg);
}
else
{
throw new RuntimeException("doesn't support this");
}
}
catch(Exception e)
{
}
}
}
Comments
Post a Comment