首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在SSIS SMTP连接管理器中指定简单身份验证的凭据?

如何在SSIS SMTP连接管理器中指定简单身份验证的凭据?
EN

Stack Overflow用户
提问于 2017-04-26 22:25:22
回答 2查看 15.5K关注 0票数 6

我们有几个发送电子邮件的asp.net web应用程序,并且MailMessage对象配置了SMTP服务器、用户名和密码。电子邮件的发送没有任何问题。

SSIS包中,我添加了一个SMTP连接管理器,并配置了smtp服务器。我设置UseWindowsAuthentication=True是因为我看不到我在哪里输入用户名/密码。

当我从SQL Server Agent运行包时,SSIS正确地发送了电子邮件,因此显然不需要用户名/密码。

那么,如果没有用户凭据,SMTP包如何发送电子邮件呢?asp.net也不需要凭据,这有意义吗?

我们都在同一个公司的网络下,而且我们都使用Exchange Server

谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-04-26 22:44:38

看看这个link

它说明程序包正在使用Sql Server代理帐户连接到主机。此外,SMTP连接管理器仅支持匿名身份验证和Windows身份验证。它不支持基本身份验证-如documentation中所述。

票数 4
EN

Stack Overflow用户

发布于 2018-07-09 22:28:26

Alan Gaylor的回答对我不起作用,但在脚本任务中执行以下操作,而不是电子邮件任务,有效:

代码语言:javascript
复制
using System.Diagnostics;
using System.Net;
using System.Net.Mail;


    public void Main()
    {
        string UserName = Dts.Variables["UserName"].Value.ToString();
        string Password = Dts.Variables["Password"].Value.ToString();
        string EmailRecipient = Dts.Variables["EmailRecipient"].Value.ToString();
        string EmailSender = Dts.Variables["EmailSender"].Value.ToString();

        string SMTPEndPoint = Dts.Variables["SMTPEndPoint"].Value.ToString();
        Int32.TryParse(Dts.Variables["SMTPPort"].Value.ToString(), out int SMTPPort);

        string MessageSubject = Dts.Variables["MessageSubject"].Value.ToString();
        string MessageBody = Dts.Variables["MessageBody"].Value.ToString();

        MailMessage msg = new MailMessage();
        msg.To.Add(new MailAddress(EmailRecipient));
        msg.From = new MailAddress(EmailSender);
        msg.Subject = MessageSubject;
        msg.Body = MessageBody +
            "\n" +
            "\n" +
            "DISCLAIMER: The information contained in this transmission may contain privileged and confidential information. " +
            "It is intended only for the use of the person(s) named above.If you are not the intended recipient, " +
            "you are hereby notified that any review, dissemination, distribution or duplication of this communication " +
            "is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.";


        SmtpClient client = new SmtpClient(SMTPEndPoint, SMTPPort)
        {
            EnableSsl = true,
            DeliveryMethod = SmtpDeliveryMethod.Network,
            Credentials = new NetworkCredential(UserName, Password)
        };
        try
        {
            client.Send(msg);
        }
        catch (Exception e)
        {
            Debug.WriteLine(e);
        }
        Dts.TaskResult = (int)ScriptResults.Success;
    }
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43637009

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档