The example of this article for everyone to share the implementation code of the. Net send mail, for everyone's reference, the specific contents are as follows
Key code:
Need to reference namespaces:
Using System.Net.Mail;Using System.Net;
MailMessage mailobj = new MailMessage ();
Mailobj.from = new MailAddress ("mayun@qq.com"); Sender's email address
mailObj.To.Add ("mahuateng@qq.com"); Recipient email address
mailobj.subject = "account activation"; Them
I often use a free gmail.com mailbox because it has a large capacity, but we often encounter unexpected errors when using. NET programming to send emails. The most common is:
(1) The operation has timed out.(2) A similar prompt is displayed:"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 must issue a starttls command first ...."
The main cause of this error is:(1) The pop settings are incorrect;(2) This is caused by incorrect
For. NET, since 2.0, e-Mail has been a very easy thing to do. Below I give a C # mass mail instance, do a more detailed note, I hope to have a friend need help.Introducing namespacesUsing system.net;Using System.Net.Mail;SmtpClient smtp = new SmtpClient (); Instantiate a SmtpClientSmtp. Deliverymethod = Smtpdeliverymethod.network; Set the outbound mode of SMTP to NetworkSmtp. Enablessl = FALSE;//SMTP Whethe
Using system. net;Using system. net. mail;
Smtpclient SMTP = new smtpclient (); // instantiate a smtpclientsmtp. deliverymethod = smtpdeliverymethod. network; // set the SMTP outbound method to networksmtp. enablessl = false; // whether SSL encryption is enabled on the SMTP server
SMTP. Host = "smtp.163.com"; // specify the SMTP server address SMTP. Port = 25; // specify the SMTP server port, which is 25 by
Group emailIt is an indispensable "skill" for websites and some promotional applications ".
For. net, it is very easy to send emails from 2.0. Next, I will give an example of sending an email in C # group. I have made some detailed annotations and hope to help some friends who need it. Read this blog, // introduce the namespace
Using system. net;Using system. net. mail;
Smtpclient SMTP = new smtpclient ();
try {mailmessage mm = new MailMessage (); MailAddress Fromma = new MailAddress ("xxxx@qq.com"); MailAddress Toma = new MailAddress ("MMMMMMM@qq.com", null); Mm. from = Fromma; Recipient mm. To.add ("MMMMMM@qq.com"); Mailbox title mm. Subject = "Hello Dear:"; Mm. Isbodyhtml = true; Message content mm. Body = "Hello Mr Meteor!" "; Encoding format for content mm. bodyencoding = Sy
Direct appendix to the main code barstatic void Main (string[] args){SmtpClient client = new SmtpClient ("smtp.126.com");MailAddress from = new MailAddress ("*****@126.com", "* * *", ENCODING.UTF8);//Outgoing MailMailAddress to = new MailAddress ("* * * * * * @qq. com", "* * * *", ENCODING.UTF8);//mail addressMailMessage message = new MailMessage (from, to);Attachment atta = new Attachment (@ "C:\Users\HBD\
For. NET, since 2.0, e-Mail has been a very easy thing to do. Below I give a C # mass mail instance, do a more detailed note, I hope to have a friend need help.Introducing namespacesUsing System.Net;Using System.Net.Mail;SmtpClient smtp = new SmtpClient (); Instantiate a SmtpClientSmtp. Deliverymethod = Smtpdeliverymethod.network; Set the outbound mode of SMTP to NetworkSmtp. Enablessl = FALSE;//SMTP Whethe
1. Tools and resources used: VS2012 provides SmtpClient class (System.NET.Mail) in the. NET Frameword class Library2. Operation3, the specific code implementation is as follows:Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.linq;using system.text;using system.threading.tasks;using system.windows.forms;using System.Net.Mail; Using System.net.mime;using system.net;using Sy
1. Tools and resources used: VS2012 provides smtpclient class (System.NET.Mail) in the. NET Frameword class Library 2. Operation3, the specific code implementationusingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;usingSystem.Net.Mail;usingSystem.Net.Mime;usingSystem.Net;usingSystem.IO;namespaceIntelligen
Using System;Using System.Net;Using System.Net.Mail;Using System.Text;Namespace Sendmaildemo{Class Program{static void Main (string[] args){SmtpClient client = new SmtpClient ("smtp.goodix.com");MailAddress from = new MailAddress ("[Email protected]", "the Address this Mail Send from", Encoding.UTF8);Constructs a recipient Address objectMailAddress to = new MailAddress ("[Email protected]", "the Address thi
// Introduce the namespace using System. net; using System. net. mail; SmtpClient smtp = new SmtpClient (); // instantiate a SmtpClientsmtp. deliveryMethod = SmtpDeliveryMethod. network; // set the smtp outbound method to Networksmtp. enableSsl = false; // whether the smtp server enables SSL-encrypted smtp. host = "smtp.163.com"; // specify the smtp server address smtp. port = 25; // specify the smtp server
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.