Do it yourself and implement the source code of the mail group. net step by step (2)
-- Parameter settings
Author: Yangtze River Tributary
Keywords:. net, email, mass mailing
In the preceding example, A mailsetting. CS class is used to store the parameters for confirming the sent mail.
Because it is your own use, you can directly use a configuration library support file on the webmis. Net quick development platform to add database access emails for future expansion. The following are configuration parameters. For details, see other parameters.
Of course, you can define a window by yourself. You can add several controls to the window to correspond to the variables of this class, or you can add them on the app. add settings in config. Otherwise, someone will say that the source code is spoofed because the DLL that can be replaced at the same time :)
Using system; using system. Collections. Generic; using system. Text; namespace goldmailer {// <summary> /// this class mainly defines some parameters in sending and receiving. /// // Author: Yangtze River Tributary (Zhou fangyong) // Email: flygoldfish@163.com QQ: 150439795 // address: http://blog.csdn.net/flygoldfish ///★★★★★You can use this program for free, but please keep this description completely to maintain intellectual property rights★★★★★////// </Summary> public class mailsetting {// The configuration DLL of the original project is used here, you can add a window to define the corresponding variable/* configuration information <otherparameters> <parameteritem> <parametername> SMTP server </parametername> <parametervalue> smtp.163.com </parametervalue> </parameteritem> <parameteritem> <parametername> sending and receiving port number </parametername> <parametervalue> 25 </parametervalue> </parameteritem> <parametername> sender's email address </parametername> <Parameter Value> GoldPrinter@163.com </parametervalue> </parameteritem> <parametername> sender password </parametername> <parametervalue/> </parameteritem> <parametername> sender display </parametername> <parametervalue> gold print (Yangtze River Branch) </parametervalue> </parameteritem> <parametername> whether to use SSL </parametername> <parametervalue> true </parametervalue> </parameteritem> </otherparameters> */priv Ate string _ smtpserver = ""; private int _ smtpport = 25; private bool _ smtpssl = false; private string _ sendermail = ""; private string _ senderpassword = ""; private string _ senderdisplay = ""; private string _ replytomail = ""; private string _ replytodisplay = ""; # region attributes... /// <summary> /// obtain or set the SMTP server // </Summary> Public String smtpserver {get {return _ smtpserver;} set {_ smtpserver = Value ;}//< summary> /// get or set the sending and receiving port number /// </Summary> Public int smtpport {get {return _ smtpport ;} set {_ smtpport = value ;}} /// <summary> /// obtain or set whether to use SSL // </Summary> Public bool smtpssl {get {return _ smtpssl ;} set {_ smtpssl = value ;}} /// <summary> /// get or set the sender's email address // </Summary> Public String sendermail {get {return _ sendermail ;} set {_ sendermail = value ;}/// <summary> /// Get or set the sender password // </Summary> Public String senderpassword {get {return _ senderpassword;} set {_ senderpassword = value ;}} /// <summary> /// get or set the sender display information /// </Summary> Public String senderdisplay {get {return _ senderdisplay ;} set {_ senderdisplay = value ;}/// <summary> /// obtain or set the recipient's reply to the email. /// </Summary> Public String replytomail {get {return _ replytomail;} set {_ replytomail = value ;}} /// <summary> /// obtain or set the recipient's reply to the email display name. /// </Summary> Public String replytodisplay {get {return _ replytodisplay;} set {_ replytodisplay = value ;}# endregion attribute... /// <summary> /// create a new instance of the object. /// </Summary> Public mailsetting () {loadconfig () ;}/// <Param name = "senderpassword"> the specified password takes precedence over the configuration. </Param> Public mailsetting (string senderpassword): this () {_ senderpassword = senderpassword ;} /// <summary> /// load configuration information /// </Summary> Public void loadconfig () {webmis. framework. template. config. systemconfig Config = new webmis. framework. template. config. systemconfig (); Config = config. open ("config \ config. XML "); _ smtpserver = config. getparametervalue ("SMTP server"); int Port = 0; Int. tryparse (config. getparametervalue ("sending and receiving port number"), out port); If (Port> 0) {_ smtpport = port;} _ sendermail = config. getparametervalue ("sender email"); _ senderpassword = config. getparametervalue ("sender password"); _ senderdisplay = config. getparametervalue ("sender display"); If (config. getparametervalue ("whether to use SSL "). tolower (). trim () = "true") {_ smtpssl = true;} else {_ smtpssl = false;} // reply to the email _ replytomail = config. getparametervalue ("Reply to email"); _ replytodisplay = config. getparametervalue ("Reply to display ");}}}
At this point, the mail sending function is basically complete. First, a download location is provided:
Http://download.csdn.net/detail/flygoldfish/4484682
In the next article, we will complete the feedback on Group Sending by single point, successful email sending failure, and use the thread to send the mail so that the mail can be canceled on the way.
For information on source code download, visit:
Http://blog.csdn.net/flygoldfish
Disclaimer: This article is copyrighted by Zhou fangyong. You are welcome to reprint it. Please keep the complete content and source.
Flygoldfish@163.com