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;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
System.Net.Mail.SmtpClient client = new SmtpClient("smtp.qq.com");
client.UseDefaultCredentials = false;
client.Credentials = new System.Net.NetworkCredential("xxxx@qq.com", "yyyyy");
client.DeliveryMethod = SmtpDeliveryMethod.Network;
MailAddress addressFrom = new MailAddress("xxxx@qq.com", "xxxx");
MailAddress addressTo = new MailAddress("test@gmail.com", "test");
System.Net.Mail.MailMessage message = new MailMessage(addressFrom, addressTo);
message.Sender = new MailAddress("xxxx@qq.com");
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;
message.Subject = "test";
client.Send(message);
}
}
}