Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# Send Email using Process.Start

Tags:

c#

email

outlook

I want to send simple email with no attachment using default email application.

I know it can be done using Process.Start, but I cannot get it to work. Here is what I have so far:

string mailto = string.Format("mailto:{0}?Subject={1}&Body={2}", "[email protected]", "Subject of message", "This is a body of a message");
System.Diagnostics.Process.Start(mailto);

But it simply opens Outlook message with pre-written text. I want to directly send this without having user to manually click "Send" button. What am I missing?

Thank you

like image 809
Robert J. Avatar asked Oct 31 '25 19:10

Robert J.


1 Answers

You need to do this :

string mailto = string.Format("mailto:{0}?Subject={1}&Body={2}", "[email protected]", "Subject of message", "This is a body of a message");
mailto = Uri.EscapeUriString(mailto);
System.Diagnostics.Process.Start(mailto);
like image 75
Ignac Avatar answered Nov 02 '25 09:11

Ignac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!