• Send Mail C#


    Note About Generate and Send Email automatically.

    1. Toolset support:
      .Net support a Interop Call to outlook, detail refer link, MailItem.

    2. What we can do with this?
      Generate the Draft Email includeing To,CC,Subject,body,Attachment. We can also listen to the outlook operation, that is Send or Close. refer

    3. code snippet.

    public static Microsoft.Office.Interop.Outlook.MailItem mail = null;
    
    mail = new Microsoft.Office.Interop.Outlook
            .Application()
            .CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
            as Microsoft.Office.Interop.Outlook.MailItem;
            mail.To = (EmailInfo.EmailRecipients ?? string.Empty).Replace(",", ";");
            mail.CC = string.IsNullOrWhiteSpace(emailCCTo) ? "" : emailCCTo.Replace(",", ";");
            mail.Subject = EmailInfo.EmailSubject;
            if (EmailInfo.FilePath != null && EmailInfo.FilePath != "")
            {
                foreach (var each in EmailInfo.FilePath.Split(';'))
                {
                    mail.Attachments.Add(each);
                }
            }
            mail.Display(mail);
            mail.HTMLBody = isDefaultSignature ?
                            (EmailInfo.EmailBody + mail.HTMLBody) :
                            EmailInfo.EmailBody;
            ((Microsoft.Office.Interop.Outlook.ItemEvents_10_Event)mail).Send +=
                  new Microsoft.Office.Interop.Outlook.ItemEvents_10_SendEventHandler(isSent_Handle);
                           
    
  • 相关阅读:
    传递函数笔记
    模糊控制算法详细讲解
    SDRAM学习笔记
    基于STM32的CRC校验说明
    如何把图片设置成24位图/8位图??
    C2MIF软件使用说明
    ROM和RAM的内存详细说明
    Logback配置
    Logback使用
    common-logging源码解析
  • 原文地址:https://www.cnblogs.com/kongshu-612/p/7424019.html
Copyright © 2020-2023  润新知