Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open new email with attachment in Windows 10 Mail App

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:

  1. Using EML files, as per https://stackoverflow.com/a/25586282/2102158

    • The Mail app does not register itself to open EML files
  2. Using the MAPI32.dll etc. (I used the code from https://github.com/metageek-llc/inSSIDer-2/blob/master/MetaScanner/UnhandledException/MapiMailMessage.cs)

    • A dialog box pops up saying there is no email program registered. It seems the mail app does not interact with MAPI
  3. Using mailto: links.

    • The mail program opens, but it does not respect Attachment= or Attach= parameters

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

like image 719
Jon N Avatar asked Aug 10 '15 10:08

Jon N


People also ask

Why can't I open emails with attachments?

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.

How do I open an attachment in Windows Mail?

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.


1 Answers

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)));
like image 157
Antony Raj Avatar answered Oct 16 '22 11:10

Antony Raj