I am trying to add a feature to my C# / .Net app for a user to email a file. When a user has Outlook installed, I can successfully use the Outlook interop APIs to do exactly what I want. However on a new Windows 10 install, I cannot work out how to open an email with an attachment in the default Mail app, which is from the Windows Store.
I have tried:
Using EML files, as per https://stackoverflow.com/a/25586282/2102158
Using the MAPI32.dll etc. (I used the code from https://github.com/metageek-llc/inSSIDer-2/blob/master/MetaScanner/UnhandledException/MapiMailMessage.cs)
Using mailto: links.
Also
Windows.ApplicationModel.Email.EmailMessage seems to be only availble on phones.
I do not want to use SMTP to send the message server side.
I also tried the MS-UNISTORE_EMAIL: and OUTLOOKMAIL: url schemes, which are associated to the Mail app, they seemed to behave the same as mailto:
There does not seem to be any way to start the Mail app from the command line
Unrecognized file format One of the most common reasons why you can't open an e-mail attachment is because your computer doesn't have the necessary program installed to recognize the file format.
Open an attachmentIn the message list, select the message that has the attachment. In the Reading Pane, double-click the attachment. You can also right-click the message that has the attachment and choose View Attachments.
Try this:
a href='mailto:[email protected]?Subject=yoursubject&Body=yourbody&Attachment=file path '
Or try by using file upload to attach the file in mail:
Msg.Attachments.Add(new Attachment(FileUpload1.FileContent, System.IO.Path.GetFileName(FileUpload1.FileName)));
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