桌面程序通过smtp发送邮件简单例子 Winform send email sample (desktop application send email via smtp)

 

MailMessage theMailMessage = new MailMessage("[email protected]", "[email protected]");
theMailMessage.Body = "body email message here";
theMailMessage.Attachments.Add(new Attachment("pathToEmailAttachment"));
theMailMessage.Subject = "Subject here";
 
SmtpClient theClient = new SmtpClient("IP.Address.Of.Smtp");
theClient.UseDefaultCredentials = false;
System.Net.NetworkCredential theCredential = new System.Net.NetworkCredential("[email protected]", "password");
theClient.Credentials = theCredential;
theClient.Send(theMailMessage);

你可能感兴趣的:(user,application,email,WinForm)