如何在SSIS中或通过SQL将电子邮件发送给具有不同数据集的其他收件人?

问题描述

请建议我如何实现此目标:

emails_data

一个需要发送数据的表:

set_Of_Data

现在,使用SSIS,我们必须将数据集发送到该电子邮件。在生产中,我收到135封电子邮件,并向他们发送了包含其区域集的单独数据。

@ pp @ gmial.cpm将仅获取主题为数学的数据。

我不知道如何创建变量的传递方式。

有人可以帮我吗?

解决方法

我经常使用这种方法发送电子邮件:

    public static void SendEmail(List<string> to,string subject,string body,string filepathName = null)
    {
        using (MailMessage mail = new MailMessage())
        {
            string from = ConfigurationManager.AppSettings["EmailFrom"];

            SmtpClient SmtpServer = new SmtpClient("your email server"); 

            mail.From = new MailAddress(from);
            foreach(string t in to)
                mail.To.Add(new MailAddress(t));

            mail.Subject = subject;

            mail.ReplyToList.Add("your reply to email");
            mail.IsBodyHtml = true;
            mail.Body = body;
            mail.Bcc.Add("enter your email if you want to be copied");

            if (filepathName != null)
            {
                Attachment file;
                file = new Attachment(filepathName);
                mail.Attachments.Add(file);
            }

            SmtpServer.Port = 2525; //this is unique to you
            SmtpServer.Credentials = new NetworkCredential(from,ConfigurationManager.AppSettings["EmailPassword"]);


            SmtpServer.EnableSsl = true;
            SmtpServer.Send(mail);
            
        }
    }

这不能完全解决您的问题,但可以让您选择直接从SSIS脚本任务发送HTML电子邮件。

您将无法使用配置管理器,需要对其进行“硬编码”。