gmail的smtp采用了ssl连接: Outgoing Mail (SMTP) Server - requires TLS: smtp.gmail.com (use authentication) Use Authentication: Yes Use STARTTLS: Yes (some clients call this SSL) Port: 465 or 587
知道了gmail的发信细节,用System.Net.Mail,就是下面这段代码就可以了
using System; using System.Collections.Generic; using System.Text; using System.Net; using System.Net.Mail; namespace GMailSend