To send an email with Jamil, you must download the Jamil software and install it before using it. Then copy Jamil. DLL to the bin directory to add references. Using system; Using system. Data; Using system. Data. sqlclient; Using system. configuration; Using system. Web. util; Using system. Web. mail; Using system. net. configuration; Namespace hottiger. Web { Public class sendemail { /// <Summary> /// Send an email /// </Summary> /// <Param name = "mailtitle"> title </param> /// <Param name = "mailcontent"> content </param> /// <Param name = "mailto"> to whom the message is sent, multiple users can send messages at the same time, and multiple users are separated by ";" </param> /// <Returns> </returns> Public static bool email (string mailtitle, string mailcontent, string mailto) { Try { Jmail. Message jmail = new jmail. Message (); String subject = mailtitle; String body = mailcontent; String fromemail = configurationmanager. receivettings ["mailname"]; String toemail = mailto; // Silent attribute: If set to true, jmail will not throw an exception error. jmail. Send () will return true or false Based on the operation results Jmail. Silent = true; // Logs created by jmail, provided that the loging attribute is set to true Jmail. Logging = true; // Character Set, default: "US-ASCII" Jmail. charset = "gb2312 "; // Contentype of a letter. The default value is "text/plain"): If you send an email in HTML format, change it to "text/html. Jmail. contenttype = "text/html "; // Add recipient String [] arraymail = mailto. Split (';'); For (INT I = 0; I <arraymail. length; I ++) { Jmail. addrecipientbcc (arraymail [I], ""); } Jmail. From = fromemail; // Sender's email user name Jmail. mailserverusername = configurationmanager. receivettings ["mailuser"]; // Sender's email password Jmail. mailserverpassword = configurationmanager. receivettings ["mailpwd"]; // Set the mail title Jmail. Subject = subject; // Email content Jmail. Body = body; // Jmail sending Method Jmail. Send (configurationmanager. receivettings ["SMTP"], false ); Jmail. Close (); Return true; } Catch { Return false; } } } } <! -- Mailbox configuration web. config --> <Add key = "SMTP" value = "smtp.sina.com"/> <Add key = "mailuser" value = "XXX"/> <Add key = "mailpwd" value = "XXX"/> <Add key = "mailname" value = "xxx@sina.com"/> |