using System.Data;using Microsoft.Office.Interop.Outlook;

//通過outlook發郵件
        public static void SendMailWithOutlook(string toEmail, string bodyEmail,string subjectEmail)
        {
            try
            {
                Microsoft.Office.Interop.Outlook.Application olapp = new Microsoft.Office.Interop.Outlook.Application();
                MailItem eMail = (MailItem)olapp.CreateItem(OlItemType.olMailItem);
                eMail.Subject = subjectEmail;
                eMail.To = toEmail;
                eMail.Importance = OlImportance.olImportanceHigh;
                eMail.BodyFormat = OlBodyFormat.olFormatHTML;
                eMail.Body = bodyEmail;
                eMail.HTMLBody = bodyEmail;
                eMail.Importance = OlImportance.olImportanceLow;
                ((_MailItem)eMail).Send();
            }
            catch
            {
                MessageBox.Show("郵件未能成功能發送,可能是OUTLOOK故障,\r\n請與管理員聯繫!", "MES系統", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }

相关文章:

  • 2022-01-09
  • 2021-06-04
  • 2021-07-15
  • 2021-12-20
  • 2022-01-15
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-28
  • 2022-12-23
  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
  • 2021-06-17
相关资源
相似解决方案