我们有几个发送电子邮件的asp.net
web应用程序,并且MailMessage
对象配置了SMTP
服务器、用户名和密码。电子邮件的发送没有任何问题。
在SSIS
包中,我添加了一个SMTP连接管理器,并配置了smtp服务器。我设置UseWindowsAuthentication=True
是因为我看不到我在哪里输入用户名/密码。
当我从SQL Server Agent
运行包时,SSIS正确地发送了电子邮件,因此显然不需要用户名/密码。
那么,如果没有用户凭据,SMTP包如何发送电子邮件呢?asp.net也不需要凭据,这有意义吗?
我们都在同一个公司的网络下,而且我们都使用Exchange Server
。
谢谢。
发布于 2017-04-26 22:44:38
看看这个link。
它说明程序包正在使用Sql Server代理帐户连接到主机。此外,SMTP连接管理器仅支持匿名身份验证和Windows身份验证。它不支持基本身份验证-如documentation中所述。
发布于 2018-07-09 22:28:26
Alan Gaylor的回答对我不起作用,但在脚本任务中执行以下操作,而不是电子邮件任务,有效:
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;
}
https://stackoverflow.com/questions/43637009
复制相似问题