Open a specified URL in a browser
You can use the process. Start method to open the specified URL in the browser. The Code is as follows.
[C #]
// Open http://bingning.net system. Diagnostics. process. Start ("http://bingning.net") in a browser; Open email software
You can use the process. Start method to open the email software (Mailer ).
The code below is an example of opening Mailer to send mail to the mailbox address "bingning@bingning.net.
[C #]
// Open the mail client and set "to" to "bingning@bingning.net" system. Diagnostics. process. Start ("mailto: bingning@bingning.net ");
Supplement: "mailto: bingning@bingning.net" and "mailto :? To = bingning@bingning.net "is the same.
Specify the plural email address
You can specify multiple email addresses by using commas (,) as described in rfc2368.
The following code is an example of specifying test1@sample.com and test2@sample.com.
[C #]
System. Diagnostics. process. Start ("mailto: test1@sample.com, test2@sample.com ");
Specify topic, content, CC, and BCC
You can use the process. Start method to specify the topic and content. The following code is an example of specifying the topic "hello.
[C #]
System. Diagnostics. process. Start ("mailto: bingning@bingning.net? Subject = Hello ");
Like the above method, the following code is an example of specifying content, CC, and BCC.
[C #]
// Sending address string to = "bingning@bingning.net"; // subject string subject = "hello"; // content string body = "welcome to the ice producer room. "; // CC string cc =" cc@bingning.net "; // BCC string BCC =" bcc@bingning.net "; // open the standard mail client system. diagnostics. process. start (string. format ("mailto: {0 }? Subject = {1} & Body = {2} & CC = {3} & BCC = {4} ", to, subject, body, CC, bcc ));
Text appears in the topic and content of the above Code. Generally, no error occurs. However, errors may occur when "&", "=", or a text change occurs, encoding settings are required.
The following code is an example of modifying the above Code using URL encoding. Because the httputility method is required, you must append system. Web. DLL to the reference. For details about the encoding class specified by the encoding method, refer to here.
[C #]
System. text. encoding ENC = system. text. encoding. getencoding ("gb2312"); // Sending address string to = "bingning@bingning.net"; // subject string subject = "hello"; subject = system. web. httputility. urlencode (subject, ENC); // content string body = "ice producer \ r \ n welcome"; body = system. web. httputility. urlencode (body, ENC); // CC string cc = "cc@bignning.net"; // BCC string BCC = "bcc@bignning.net"; // open the standard software client system. diagnostics. PR Ocess. Start (string. Format ("mailto: {0 }? Subject = {1} & Body = {2} & CC = {3} & BCC = {4} ", to, subject, body, CC, bcc ));