The use case is simple. At a certain point of time, I need to be able to show the user his familiar compose email dialog (Outlook or other) with
The mail should not be sent unless the user explicitly okays it.
I did this once back in the ol' VB6 days.. can't figure out how now.. I just remember that it was quite easy.
Managed app, C#, .net 3.0+
Update#1: Yeah seems like mailto removed support for attachments (as a security risk?). I tried
You need to include ShellExecute signature as described here. All I got from this was a 5 SE_ERR_ACCESSDENIED
and a 2 just for some variety
string sMailToLink = @"mailto:[email protected]?subject=Hey&body= yeah yeah yeah";
IntPtr result = ShellExecute(IntPtr.Zero, "open", sMailToLink, "", "", ShowCommands.SW_SHOWNORMAL);
Debug.Assert(result.ToInt32() > 32, "Shell Execute failed with return code " + result.ToInt32());
The same MailtoLink works perfectly with Process.Start... but as long as thou shalt not mention attachments.
System.Diagnostics.Process.Start(sMailToLink);
The other options are using the Outlook Object model to do this.. but I've been told that this requires you to add assembly references based to the exact version of Outlook installed. Also this would blow up if the user doesn't prefer MS for email.
The next option are Mapi and something called Mapi33.. Status still IN PROGRESS. Ears still open to suggestions.
But you can use mailto:[email protected] link in asp.net or you can start process in windows application with passing mailto:[email protected].
Open Outlook. On the Tools menu, click Options, and then click the Other tab. Under General, select the Make Outlook the default program for E-mail, Contacts, and Calendar check box. Click OK.
An email handler is a program that is run when a user clicks on an email link. It is the default or configured email client or the program associated with email links.
Windows 10 In the search bar or search icon on the bottom left of the desktop, begin typing Default App Settings. Once You see the Default App Settings option, click it. Click the Mail option, then select the program you wish to make default.
You can create a process object and have it call "mailto:[email protected]?subject=My+New+Subject". This will cause the system to act on the mailto with its default handler, however, while you can set subjects and such this wont handle adding an attachment. I'll freely admit im not entirely sure how you'd go about forcing an attachment without writing some mail plugin.
The process code is:
System.Diagnostics.Process.Start("mailto:[email protected]?subject=My+New+Subject");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With