zoukankan      html  css  js  c++  java
  • 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);
                           
    
  • 相关阅读:
    linux中断子系统
    注释规范
    linux下C获取文件的大小
    oracle 11g 修改内存示例
    联想system sr650安装windows
    iphone 手机音乐制作
    canon dpp 编辑相机raw软件
    浪潮nf5270m5 安装2012
    三种刻录工具及用法
    centos7.5 连接存储配置iscsi
  • 原文地址:https://www.cnblogs.com/kongshu-612/p/7424019.html
Copyright © 2011-2022 走看看