C # building Block module ABC (iii)

Source: Internet
Author: User
Tags mailmessage
How do I load the wait cursor?

The cursor is part of the drawing namespace. To display a specific cursor, you can refer to the document for all available types. To display the wait cursor, try the following code:


Componentsname.cursor = System.Drawing.Cursors.WaitCursor;


Back to Arrow

Cursor = Cursors.arrow


How do I get a running process on the machine?

Use the System.Diagnostics.Process class to start and stop system processes. The GetProcesses function returns all the processes that are running on the machine, and it has two definitions, one for the local machine and the other for the remote machine.


If you want to get the running process on the local machine, use getprocesses (), otherwise use GetProcesses (string machinename):


public static process[] GetProcesses ();

public static process[] GetProcesses (string);


Like what:


process[] proclist = new process[100];

ProcList = Process.getprocesses ();


for (int i=0; i<20; i++)

{

string strprocname = Proclist.processname;

int iprocid = proclist.id;;

}


Do not forget to refer to system.diagnostic and write the following line of code in the Using list:


Using System.Diagnostics;


By using the method of the Process class, we can even start, stop, or cancel a process.


How do I open the browser in my application?

Use the System.Diagnostics.Process class to start and stop a program, which can be used to start an EXE file. For example, if you want to open a URL in a browser, you can pass the URL as a parameter to the start function:


System.Diagnostics.Process.Start ("http://www.c-sharpcorner.com");


How do I open a WAV file?

You can use the PlaySound API to play a WAV file. Use Sysimport to introduce a DLL and define the API as global before using it. Take a look at the code that invokes the API below:


[Sysimport (dll= "Winmm.dll")]

public static extern long PlaySound (String lpszname, long hmodule, long dwflags);


................


PlaySound (szwavfilename, 0, 0);

How do I send a message in C #?

To implement the ability to send messages in C #, the tool you need to use is Visual C #. NET, which involves System.Web.Util and a System.Web.dll collection.


Specifically, we can use the SmtpMail class to send messages in a C # application. By default, messages are queued in the system to ensure that the caller does not cause network congestion. The SmtpMail class is defined in the System.Web.Util namespace. Before using smtpmail, you need to call the


Using System.Web.Util


There is only one member function send in this class. It is responsible for sending an email message, whether a MailMessage class or 4 parameter variables can be passed to the Send function. There are two forms of calling the Send function:


Smtpmail.send (Txtfrom.text, Txtto.text, Txtsubject.text, Txtmessage.text);


or (if you don't want to call System.Web.Util):


System.Web.Util.Smptmail.Send (fromstring, toString, subjeofthemailstring, messageofthemailstring);


There are two ways to call the Send method:


1, by passing the MailMessage as a parameter to pass:


public static void Send (MailMessage);


The MailMessage here is a class.


MailMessage MAILMSG = new MailMessage ();

MAILMSG. from = "from@fromServer.com";

MAILMSG. to = "to@toServer.com";

MAILMSG. Cc = "cc@ccServer.com";

MAILMSG. BCC = "bcc@bccServer.com";

MAILMSG. Subject = "subjectofthemailstring";

MAILMSG. BODY = "bodyofthemailstring";

Smtpmail.send (MAILMSG);



2. Direct method


public static void Send (string from, string to, string subject, String messagetext);


From= the sender's email message, to= the recipient's email message, subject=email theme, messagetext=email information subject.


Like what:


Smtpmail.send ("mcb@mindcracker.com", "webmaster@mindcracker.com", "Subject", "message body");


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.