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)
        {
            
        }
    }    
}

Comments

Popular posts from this blog

Optical Charactor Recognition (OCR) in C#

How to create a transparent window in Windows Form Application

Installing MASM on Windows (32 bit or 64 bit)