This module contains the CreateEmail procedure which allow you to create an email in the default mail client in edit mode using MailTo. It provides fallbacks to Gmail/Outlook.com.
- The created email is simple, it only supports plain text.
- There is no way to actually send the mail without the user being involved.
- CC and BCC field implementation have been commented out but you can easily reintroduce them if needed.
- No error handling, any errors occurring will trickle to the calling procedure and should be handled there. Calling the procedure is simple:
CreateEmail "john@doe.com", "about MailTo", "This is only for no frills emails"The CreateEmail procedure relies on ShellExecute to launch the default mail client using a mailto: URL. If the email window does not appear, one of the following issues is likely the cause:
Windows must have an application associated with the mailto: protocol.
If none is set, ShellExecute returns error 31 (SE_ERR_NOASSOC) and nothing opens.
Some email programs fail to register the mailto: handler correctly.
Symptoms include:
- No email window appearing
- Error 31
- The wrong application opening
mailto: URLs have practical length limits. Unencoded characters (spaces, %, &, line breaks) or very long bodies may cause:
- Silent failure
- Truncated fields
- Generic errors such as 2 (SE_ERR_FNF) or 5 (SE_ERR_ACCESSDENIED)
Certain clients—especially Outlook desktop—may:
- Ignore parameters
- Fail to open if another instance is busy
- Open a blank message instead of the expected content
In managed environments, protocol handlers like mailto: may be disabled.
This typically results in SE_ERR_ACCESSDENIED (5) or no visible action.
If the user has set Gmail or Outlook.com as the default handler via a browser:
- The browser may fail to launch
- Parameters may not be passed correctly
- The wrong profile may open
The built‑in fallback to Gmail/Outlook.com helps mitigate this scenario.
If CreateEmail fails to open a new message window, try the following steps:
Check Settings → Apps → Default apps → Choose defaults by link type → mailto
Ensure a valid desktop mail client (Outlook, Thunderbird, etc.) is selected.
Open Run (Win+R) and enter:
mailto:test@example.com
If nothing happens, the system’s mailto: association is broken.
Long bodies or unencoded characters can break the URL.
Try:
- Reducing the body length
- Ensuring proper URL encoding (spaces →
%20, line breaks →%0D%0A)
Some clients (especially Outlook) may need:
- A restart
- A profile repair
- A system reboot
On managed devices, protocol handlers may be disabled.
Contact IT if:
mailto:does nothing- You receive Access Denied errors
If the desktop handler fails, the procedure automatically falls back to:
- Gmail
- Outlook.com
This ensures the user can still compose an email even when the local handler is misconfigured.