. Net1.1
Using system. Web. mail;
Usage:
Sendsmtpemail ("100.100.100.100", "someone@xxx.com", "XXXX", "someone@xxx.com", "webtest", textbox1.text, null, null );
Method body:
Public void sendsmtpemail (string strsmtpserver, string strfrom, string strfrompass, string strto, string strsubject, string strbody, string BCC, string CC)
{
System. Web. Mail. mailmessage mail = new system. Web. Mail. mailmessage ();
Mail. bodyformat = mailformat. html;
Mail. From = strfrom;
Mail. To = strto; // separate multiple recipients with semicolons
Mail. bcc = BCC;
Mail. Cc = cc;
Mail. Subject = "mail test !!! ";
Mail. Body = textbox1.text;
Mail. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1 ");
Mail. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendusername", strfrom );
Mail. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendpassword", strfrompass );
System. Web. Mail. mailattachment attachment = new system. Web. Mail. mailattachment ("C: \ log. log ");
Mail. attachments. Add (Attachment );
Smtpmail. smtpserver = strsmtpserver;
Smtpmail. Send (Mail );
}
. Net2.0
Using system. net. mail;
Usage:
Sendsmtpemail ("100.100.100.100", "someone@xxx.com", "XXXX", "someone@xxx.com", "webtest", textbox1.text, null, null );
Method body:
Public void sendsmtpemail (string strsmtpserver, string strfrom, string strfrompass, string strto, string strsubject, string strbody)
{
System. net. Mail. smtpclient client = new smtpclient (strsmtpserver );
Client. usedefacrecredentials = false;
Client. Credentials = new system. net. networkcredential (strfrom, strfrompass );
Client. deliverymethod = smtpdeliverymethod. Network;
System. net. Mail. mailmessage message = new system. net. Mail. mailmessage (strfrom, strto, strsubject, strbody );
System. net. Mail. Attachment attachment = new system. net. Mail. Attachment ("C: \ log. log ");
Message. attachments. Add (Attachment );
Message. bodyencoding = system. Text. encoding. utf8;
Message. isbodyhtml = true;
Client. Send (Message );
}