[.Net] 使用Outlook元件寄信

引用Microsoft.Office.Interop.Outlook

收件人可以用;隔開整串傳入


using Outlook = Microsoft.Office.Interop.Outlook;
public static void Send(string to, string cc, string subject, string body, params string[] files)
{
    var app = new Outlook.Application();
    Outlook.MailItem mail = app.CreateItem(Outlook.OlItemType.olMailItem);
    mail.Subject = subject;
    mail.Body = body;
    mail.To = to;
    mail.CC = cc;
    foreach (string fi in files)
        mail.Attachments.Add(fi);
    mail.Send();
}

Taiwan is a country. 臺灣是我的國家