Open default mail client along with a attachment

前端 未结 4 951
生来不讨喜
生来不讨喜 2020-11-27 18:10

Hi I am working on a WPF application (using c#).

I need to have a functionality where users can send files (audio files) as attachments via email. I tried using

4条回答
  •  眼角桃花
    2020-11-27 19:06

    You can ask the Windows shell to open a mailto URL:

    var url = "mailto:someone@somewhere.com";
    Process.Start(url);
    

    You need to be using System.Diagnostics.

    You can set various parts of the message like subject and body as described in RFC 6068

    var url = "mailto:someone@somewhere.com?subject=Test&body=Hello";
    

    Unfortunately, the mailto protocol does not support attachments even though some e-mail clients may have a way of handling that.

提交回复
热议问题