下麵代碼內容是關於C# 發送電子郵件片段的代碼,應該對各位有所用途。 using System;using System.Web;using System.Web.Mail;public class TestSendMail{ public static void Main() { try { Ma ...
下麵代碼內容是關於C# 發送電子郵件片段的代碼,應該對各位有所用途。
using System;
using System.Web;
using System.Web.Mail;
public class TestSendMail
{
public static void Main()
{
try
{
MailMessage message = new MailMessage();
message.From = [email protected];
message.To = [email protected];
message.Cc = ;
message.Bcc = ;
message.Subject = Subject;
message.Body = Content of message;
message.Attachments.Add(new MailAttachment(c:\attach.txt, MailEncoding.Base64));
SmtpMail.Send(message);
System.Console.WriteLine(Message has been sent);
}
catch(Exception ex)
{
System.Console.WriteLine(ex.Message.ToString());
}
}
}