2012-02-25
Generate emails via mailto URLs on Node.js
Labels: desktop, dev, javascript, nodejs
mailto URL syntax
"mailto:" recipients ( "?" key "=" value ("&" key "=" value)* )?- recipients: comma-separated email addresses (no spaces; Outlook needs semicolons instead of commas)
- value: should be URL-encoded (e.g. space becomes %20)
- key: subject, cc, bcc, body
Using mailto URLs on Node.js
The npm module openurl allows you to tell the operating system to open a URL. It also comes with a mailto() function that constructs well-formed mailto URLs. Example:require("openurl").mailto(["john@example.com", "jane@example.com"], { subject: "Hello!", body: "This is\na generated email!\n" });Naturally, the same technique also works with other programming languages: