has just entered the ranks of the "development" has always had an idea when can I give me a huge database of user information to send recommendations to each user's mailbox?
Just entered "programming two months" I use SMTP to send webmail, first on the common mail server on the code
/********************************** here is the mail server name POP3 protocol using the pop address SMTP using smtp*****************************************/
Gmail (google.com)
POP3 Server address: pop.gmail.com
SMTP Server address: smtp.gmail.com
21cn.com:
POP3 Server address: pop.21cn.com
SMTP server address: smtp.21cn.com sina.com:
Sina.com:
POP3 Server address: pop3.sina.com.cn
SMTP Server address: smtp.sina.com.cn
Tom.com:
POP3 Server address: pop.tom.com
SMTP Server address: smtp.tom.com
163.com:
POP3 Server address: pop.163.com
SMTP Server address: smtp.163.com
263.net:
POP3 Server address: pop3.263.net
SMTP Server address: smtp.263.net
X263.net:
POP3 Server address: pop.x263.net
SMTP Server address: smtp.x263.net
263.net.cn:
POP3 Server address: pop.263.net.cn
SMTP Server address: smtp.263.net.cn
Elong.com:
POP3 Server address: pop3.elong.com
SMTP Server address: smtp.elong.com
China.com:
POP3 Server address: pop.china.com
SMTP Server address: smtp.china.com
Sohu.com:
POP3 Server address: pop3.sohu.com
SMTP Server address: smtp.sohu.com
Etang.com:
POP3 Server address: pop.etang.com
SMTP Server address: smtp.etang.com
Yahoo.com:
POP3 Server address: pop.mail.yahoo.com
SMTP Server address: smtp.mail.yahoo.com
yahoo.com.cn:
POP3 Server address: pop.mail.yahoo.com.cn
SMTP Server address: smtp.mail.yahoo.com.cn
/***************************************************** Here is a message class method properties are all inside ******************************** **********/
Using System;
Using System.Net.Mail;
Using System.Text;
Namespace Consoleapplicationsqlservermaximum
{
Internal class Emailconfig
{
<summary>
Sent by
</summary>
public string Mailfrom {get; set;}
<summary>
Recipient
</summary>
Public string[] Mailtoarray {get; set;}
<summary>
Cc
</summary>
Public string[] Mailccarray {get; set;}
<summary>
Title
</summary>
public string Mailsubject {get; set;}
<summary>
Body
</summary>
public string Mailbody {get; set;}
<summary>
Sender Password
</summary>
public string Mailpwd {get; set;}
<summary>
SMTP mail server
</summary>
public string Host {get; set;}
<summary>
Whether the body is in HTML format
</summary>
public bool isbodyhtml {get; set;}
<summary>
Attachment
</summary>
Public string[] Attachmentspath {get; set;}
public bool Send ()
{
Initializes a mailaddress instance with the specified mail address
MailAddress maddr = new MailAddress (mailfrom);
Initializing an MailMessage instance
MailMessage mymail = new MailMessage ();
Add a mail address to a collection of recipient addresses
if (Mailtoarray! = null)
{
for (int i = 0; i < mailtoarray.length; i++)
{
MYMAIL.TO.ADD (Mailtoarray[i]. ToString ());
}
}
Add an email address to the CC recipient address Collection
if (Mailccarray! = null)
{
for (int i = 0; i < mailccarray.length; i++)
{
MYMAIL.CC.ADD (Mailccarray[i]. ToString ());
}
}
Sender Address
Mymail.from = maddr;
The title of the e-mail
Mymail.subject = Mailsubject;
The encoding used for the subject content of the e-mail
mymail.subjectencoding = Encoding.UTF8;
Email body
Mymail.body = Mailbody;
Encoding of the body of the e-mail
mymail.bodyencoding = Encoding.default;
mymail.priority = Mailpriority.high;
mymail.isbodyhtml = isbodyhtml;
Add an attachment with an attachment
Try
{
if (Attachmentspath! = null && attachmentspath.length > 0)
{
Attachment attachfile = null;
foreach (string path in Attachmentspath)
{
Attachfile = new Attachment (path);
MYMAIL.ATTACHMENTS.ADD (Attachfile);
}
}
}
catch (Exception err)
{
throw new Exception ("error when adding an attachment:" + err);
}
SmtpClient smtp = new SmtpClient ();
Specify the sender's e-mail address and password to verify sender identity
Smtp. Credentials = new System.Net.NetworkCredential (Mailfrom, mailpwd);
Setting up an SMTP mail server
Smtp. host = host;
Try
{
Send a message to an SMTP mail server
Smtp. Send (MyMail);
return true;
}
catch (System.Net.Mail.SmtpException ex)
{
Console.WriteLine (ex);
return false;
}
}
}
}
/******************** Here I use a console application that also supports Web winfrom MVC HTML JQuery, JAVASCRIPT ***********/
Using System;
Using System.Collections.Generic;
Using System.Data.SqlClient;
Using System.Linq;
Using System.Net;
Using System.Net.Mail;
Using System.Text;
Using System.Threading.Tasks;
Namespace Consoleapplicationsqlservermaximum
{
Class Program
{
static void Main (string[] args)
{
{
Emailconfig email = new Emailconfig ();
Email.mailfrom = "*********@263.com"; Sender Account
Email.mailpwd = "*********";//Sender Password
Email.mailsubject = "My first 263 message header";//Send Message header
Email.mailbody = "My first 263 message content";//Send Message body
Email.isbodyhtml = true; Whether the body is in HTML format
Email.host = "Smtp.263.net"; SMTP mail server
Email.mailtoarray = new string[] {"[email protected]", "[email protected]"};//recipient can be an array here's a simple case of not requesting a database
Email.mailccarray = new string[] {"[email protected]"};//cc
if (email. Send ())
{
Console.WriteLine ("Y");
}
Else
{
Console.WriteLine ("N");
}
}
}
}
}
/************************************************************ Map ************************************************ ***********/
Summarize:
1. Nothing is difficult undone (as long as you want to do not have to do)
2. Of course this is just one of the ways that this way pros and cons SMTP (General QQ mailbox is closed by default: Reasons to block spam messages such as)
3. Send mail port A lot of advantages and disadvantages of each of you friends use
. Net Mail SMTP Send Webmail