title: How do I open the default mail program with a Subject and Body in a cross-platform way?
body: <p>How do I open the default mail program with a Subject and Body in a cross-platform way?</p>
  
  <p>Unfortunately, this is for a a client app written in Java, not a website.</p>
  
  <p>I would like this to work in a cross-platform way (which means Windows and Mac, sorry Linux). I am happy to execute a VBScript in Windows, or AppleScript in OS X. But I have no idea what those scripts should contain. I would love to execute the user's default program vs. just searching for Outlook or whatever.</p>
  
  <p>In OS X, I have tried executing the command:</p>
  
  <pre><code>open mailto:?subject=MySubject&amp;body=TheBody
  </code></pre>
  
  <p>URL escaping is needed to replace spaces with <code>%20</code>.</p>
  
  <p><strong>Updated</strong> On Windows, you have to play all sorts of games to get <code>start</code> to run correctly. Here is the proper Java incantation:</p>
  
  <pre><code>class Win32 extends OS {
      public void email(String subject, String body) throws Exception {
          String cmd = "cmd.exe /c start \"\" \"" + formatMailto(subject, body) + "\"";
          Runtime.getRuntime().exec(cmd);
      }
  }
  </code></pre>