using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
public void Send(string strFrom,string strTo, string strSubject, string strBody)
{
}
private void button1_Click(object sender, EventArgs e)
{
SmtpClient client = new SmtpClient("smtp.163.com", 25);
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("账户", "密码");
client.DeliveryMethod = SmtpDeliveryMethod.Network;
MailAddress From = new MailAddress("你的邮箱(虚的)", "姓名");
MailAddress To = new MailAddress("要发送人的邮箱");
MailMessage message = new MailMessage(From, To);
message.Sender = new MailAddress("主题");//这是主题行
message.Body = "这是一个测试邮件,这里是内容部份!";
message.BodyEncoding = System.Text.Encoding.Default;
message.IsBodyHtml = true;
client.Send(message);
}
}
}