= System. text. encoding. UTF8; // The Message Content Encoding msg. isBodyHtml = false; // whether the message is an HTML message msg. priority = MailPriority. high; // mail priority SmtpClient client = new SmtpClient (); client. credentials = new System. net. networkCredential ("1234567@qq.com", "password"); // registered mailbox and password, as far as QQ mailbox is concerned, if you set an independent
A few days ago, students asked how to send e-mail in C #, a lot of online articles, conveniently found an article, to students, let him go to see. As a result, the day has not been fixed, had to look carefully. e-mail sent in C #, many articles on the internet are used smtpclient, there are System.Web.Mail, but System.Web.Mail is not recommended. The following is an e-mail message that is common on the Web:
1 MailMessage MyEmilMessage=new MailMessage
Using System.Collections.Generic;
Using System.Text;
Using System.Net;
Using System.Net.Mail; Try
{
The code is rigidly defined as GB2312
Encoding Encoding = encoding.getencoding (936);
MailMessage message = new MailMessage (
New MailAddress ("Own Mailbox", "5", encoding),//The first is the address of the sender, the second parameter is the sender
New MailAddress (TextBox1.Text));//Addressee's mailbox
message.subjectencoding = encoding;
Message.subject =textbox2.text;//Title
message.bodyencoding
Routine 1
The format of the email content call image is:
The server code for sending an email is:
SmtpClient: email sending object // Code omitted
Copy codeThe Code is as follows:System. Net. Mail. MailMessage mailMessage = new System. Net. Mail. MailMessage ();MailMessage. From = "sender's mailbox ";MailMessage. To. Add ("recipient email list ");MailMessage. CC. Add ("CC Mail List ");MailMessage. Subject = subject;AlternateView htmlBody = AlternateV
Author/Source: Blueski compiled (contains 2 articles, the previous article used SUN.NET.SMTP, the latter used a javamail.
We can send mail through any JSP engine (such as JSWDK) that supports the SUN.NET.SMTP package in the Sun specification.
(Warning: Use the built-in internal Sun specification package, which will affect the portability of your JSP programs.) )
The following scriptlet use the SmtpClient class to send email in a JSP file.
String from=
class service1: servicebase {public service1 () {initializecomponent ();} protected override void onstart (string [] ARGs) {// when the minute is an even While (datetime. now. second % 2 = 0) {// defines the mail client smtpclient client = new smtpclient (configurationmanager. appsettings ["smtpclient"], Int. parse (configurationmanager. appsettings ["smtpprot"]
Recently, I am working on the mail sending interface to inform everyone of the problems and solutions I have encountered. I hope it will be helpful to those who know the mail.Some code of the original program is as follows:// Set the sender address, recipient address, title, and topic of the email.Mailmessage mail = new mailmessage ("xxxxxxx@sina.com", "zzzzzzz@sina.com", "title", "topic ");// Set the subject formatMail. bodyencoding = encoding. utf8;// Set whether the subject format is htmlMail
[Download source code]
Send an email in asp.net 2.0
Author: webabcd
1. Add the following configuration information (host-smtp service address, port-port number, userName-user name, and password-password) to
2. aspx page HTML code SenderRecipientTopicAttachmentContent
3. instantiate a MailMessage and set its attributes MailMessage mm = new MailMessage (emailfrom. Text, emailto. Text );Mm. Subject = subject. Text;Mm. Body = body. Text;// HTML formatMm. IsBodyHtml = true;// Add an attachmentMm.
parameter, which represents the file type of the attachment, can be used without specifying return mm; } public bool SendEmail (string fromemailaddress, String toemailaddress,string emailtitle,string emailcontent,string Host , String port,string fromemailuser,string desemailuser,string fromemailpass) { BOOL B=false; String message=string. Empty; MailMessage mailessage =this.mailmessage (fromemailaddress,desemailuser,toemailaddress,emailtitle,emailcontent);
Req.getremotehost ();}%>Out.print ("In General,lao Lee are not baddie");%> 12, if the browser has been closed cookies, in the JSP how can I open the session to trackYou can use URL rewriting as follows:hello1.jspInteger num = new integer (100);Session.putvalue ("num", num);String URL =response.encodeurl ("hello2.jsp");%> hello2.jspInteger i= (integer) session.getvalue ("num");Out.println ("Num value in the session is" +i.intvalue ());%> 13, in the JSP can send email?You can use the Sun's priv
(HttpServletRequest req) {
HttpSession ses = req.getsession ();
...
return Req.getremotehost ();
}
%>
Out.print ("In General,lao Lee are not baddie");
%>
12, if the browser has been closed cookies, in the JSP how can I open the session to track
You can use URL rewriting as follows:
hello1.jsp
Integer num = new integer (100);
Session.putvalue ("num", num);
String URL =response.encodeurl ("hello2.jsp");
%>
hello2.jsp
Integer i= (integer) session.getvalue ("num");
Out.println ("Num value in
, Eventtxt, EntryType, EventID);
}
Smtpappender
... {
#if net_2_0
. NET 2.0 has a new API for SMTP email System.Net.Mail
This API supports credentials and multiple hosts correctly.
The old API is deprecated.
Create and configure the SMTP client
SmtpClient smtpclient = new SmtpClient ();
if (m_smtphost!= null m_smtphost.length > 0)
... {
Smtpclient.host = M_smt
= req.getsession ();......Restitution of Req.getremotehost ();}%>Out.print ("In general, Lao Lee is not a baddie quot;);"%>12, if the browser has been closed cookies, in the JSP how can I open the session to trackYou can use URL rewriting as follows:hello1.jspInteger num = new integer (100);Session.putvalue ("num", num);Rope URL =response.encodeurl ("hello2.jsp");%>hello2.jsphello2.jspInteger i= (integer) session.getvalue ("num");At the meeting of the OUT.PRINTLN ("num value is" +i.intvalue ()
) {
HttpSession ses = req.getsession ();
...
return Req.getremotehost ();
}
%>
Out.print ("In General,lao Lee are not baddie");
%>
12, if the browser has been closed cookies, in the JSP how can I open the session to track
You can use URL rewriting as follows:
hello1.jsp
Integer num = new integer (100);
Session.putvalue ("num", num);
String URL =response.encodeurl ("hello2.jsp");
%>
hello2.jsp
Integer i= (integer) session.getvalue ("num");
Out.println ("Num value in the session is" +i.intvalue
) {
HttpSession ses = req.getsession ();
...
return Req.getremotehost ();
}
%>
Out.print ("In General,lao Lee are not baddie");
%>
12, if the browser has been closed cookies, in the JSP how can I open the session to track
You can use URL rewriting as follows:
hello1.jsp
Integer num = new integer (100);
Session.putvalue ("num", num);
String URL =response.encodeurl ("hello2.jsp");
%>
hello2.jsp
Integer i= (integer) session.getvalue ("num");
Out.println ("Num value in the session is" +i.intvalue
asp.net| Send mail
These two days because you want to do a Web page that collects user submissions and then sends messages to a specific mailbox. To send a message inside asp.net 2.0, you can use the System.Net.Mail class below. Http://www.systemnetmail.com/faq/2.1.aspx This address is written by a System.Net.Mail author as if it were an MSDN-like FAQ, which you can refer to when looking at the code. Do not say anything, the following post code it, after all, the code is the most important:
1pro
Omail.body = TextBox3.Text; Message content
Omail.isbodyhtml = true; Specify message format, support HTML format
omail.bodyencoding = System.Text.Encoding.GetEncoding ("GB2312");/the encoding used by the message
Omail.priority = mailpriority.high;//The priority of the message is high
Send mail server
SmtpClient client = new SmtpClient ();
Client.Host = "mail.cpp114.com"; Specify mail server
Cli
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.