0

I've been all day trying to find code that would allow me to launch the default email system with an attachment but I did not succeed. My app is written in python, and runs on windows. I did not succed with python with this post Python: launch default mail client on the system so, I tried with C# with this Post Open default mail client along with a attachment and some other information I found on the Internet. In this post the following line of code:

var mailWriter = mailWriterContructor.Invoke(new object[] { filestream }); 

raises an Error:

System.NullReferenceException: 'Object reference not set to an instance of an object.'

I found the solution with Start-Process mailto:... and it opens the default email system with the attachment argument ignored, this is the code I use here:

C:\SomeDir> Start-Process "mailto:some.guy@someplace.com?subject=an email&body=see attachment&attachment='cost example.xlsx'"

The default email System is Thunderbird if that matters. I will keep searching for a solution. Any idea is welcome. Thanks.

  • What does this mean 'but the attachment argument does not seem to work'? Do you get an error? Can you share your current code? – Markus Meyer Jun 28 '22 at 14:58
  • @MarkusMeyer I edited the question. I read after that mailto utility does not support attachment. – user17838564 Jun 28 '22 at 15:05
  • ok, but your shared link to C# looks like a working solution: https://stackoverflow.com/questions/20328598/open-default-mail-client-along-with-a-attachment – Markus Meyer Jun 28 '22 at 15:06
  • May be I was not able to make it running, I'll try again. If you can help me with that code on the post I mentioned, I'll give you 100 USD. – user17838564 Jun 28 '22 at 15:08
  • Use the full path to the file. Even then it is up to the e-mail client if it wants to parse the protocol elements that way... – Anders Jun 29 '22 at 12:31

0 Answers0