Use a browser to open a specified URL and mail software)

Source: Internet
Author: User
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 ));


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.