4

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

6
  • 4
    Why are expecting that to be like that? I'm glad no random application can send email using my email program without me knowing or seeing anything. Commented Oct 16, 2014 at 12:03
  • use the SmtpClient class. Commented Oct 16, 2014 at 12:04
  • If problem occurs within the application, I want to automatically send error log to system administrator. Commented Oct 16, 2014 at 12:05
  • Automating Outlook via COM Interop is the best way if for whatever reason you must use Outlook. For the command line see; Sending email from Command-line via outlook without having to click send. For a general solution for other e-mail clients, your out of luck - there is no such common interface. Commented Oct 16, 2014 at 12:09
  • The process start will not fully automate the sending of the email. It will only open it ready to send (as you have seen) Commented Oct 16, 2014 at 12:10

3 Answers 3

6

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); 
Sign up to request clarification or add additional context in comments.

1 Comment

How is this different from what OP is already doing? This will not send the message automatically. It will simply be shown on the screen.
3

I'm not sure about Process.Start() this will probably always only open a mail message in the default Mail-App and not send it automatically.

But there may be two alternatives:

Comments

2

You need to do this:

SmtpClient m_objSmtpServer = new SmtpClient(); MailMessage objMail = new MailMessage(); m_objSmtpServer.Host = "YOURHOSTNAME"; m_objSmtpServer.Port = YOUR PORT NOS; objMail.From = new MailAddress(fromaddress); objMail.To.Add("TOADDRESS"); objMail.Subject = subject; objMail.Body = description; m_objSmtpServer.Send(objMail); 

2 Comments

Yes I have seen this solution, but I want to achieve this using Process.Start
I believe that using Process.Start you will not be able to do it .It will simply open the Outlook.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.