MailMessage mail = new MailMessage(); mail.To = "me@mycompany.com"; mail.From = "you@yourcompany.com"; mail.Subject = "this is a test email."; mail.Body = "this is my test email body"; SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail );
[ VB.NET ]
Dim mail As New MailMessage() mail.To = "me@mycompany.com" mail.From = "you@yourcompany.com" mail.Subject = "this is a test email." mail.Body = "this is my test email body" SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail)
2,发送Html邮件 [ C# ] MailMessage mail = new MailMessage(); mail.To = "me@mycompany.com"; mail.From = "you@yourcompany.com"; mail.Subject = "this is a test email."; mail.BodyFormat = MailFormat.Html; mail.Body = "this is my test email body.<br><b>this part is in bold</b>"; SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail );
[ VB.NET ] Dim mail As New MailMessage() mail.To = "me@mycompany.com" mail.From = "you@yourcompany.com" mail.Subject = "this is a test email." mail.BodyFormat = MailFormat.Html mail.Body = "this is my test email body.<br><b>this part is in bold</b>" SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail)