Skip to main content
 首页 » 编程设计

c#之C#中的电子邮件处理

2024年01月16日31dyllove98

我需要知道在 C#/.NET Framework 中处理电子邮件的对象名称。

请您参考如下方法:

您需要命名空间 System.Net.Mail。

Here是来自 ScottGu 博客的示例。

MailMessage message = new MailMessage(); 
message.From = new MailAddress("sender@foo.bar.com");  
 
message.To.Add(new MailAddress("recipient1@foo.bar.com")); 
message.To.Add(new MailAddress("recipient2@foo.bar.com")); 
message.To.Add(new MailAddress("recipient3@foo.bar.com"));  
 
message.CC.Add(new MailAddress("carboncopy@foo.bar.com")); 
message.Subject = "This is my subject"; 
message.Body = "This is the content"; 
 
 
SmtpClient client = new SmtpClient(); 
client.Send(message);