SQL 用于从 Gmail 向 Gmail 发送邮件的 Server 2012 SSIS 脚本任务,显示 "DTS Script :Runtime Error"
SQL Server 2012 SSIS Script Task for sending mail from Gamil to Gmail , showing "DTS Script :Runtime Error"
我正在使用 SSIS 12、SQL Server 2012、Visual Studio 2012 和 .net 4。
我的SSIS脚本任务代码(发送邮件):
// Introduction to the script task
/* The Script Task allows you to perform virtually any operation that can be accomplished in
* a .Net application within the context of an Integration Services control flow.
*
* Expand the other regions which have "Help" prefixes for examples of specific ways to use
* Integration Services features within this script task. */
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
namespace ST_20fdf0b00e2949fda158e6680c127473
{
public void Main()
{
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("raihanuahmed@gmail.com", "password");
MailMessage msg = new MailMessage();
msg.From = new MailAddress("raihanuahmed@gmail.com");
msg.To.Add(new MailAddress("raihan.csse.aiub@gmail.com"));
msg.Subject = "AW2012 ETL Process Complite";
msg.Body = string.Format("{0} records loaded into DimProduct", 0);
smtp.Send(msg);
Dts.TaskResult = (int)ScriptResults.Success;
}
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
}
}
执行此电子邮件发送脚本后,我总是收到
"DTS Script :Runtime Error"
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[]
arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags
bindingFlags, Binder binder, Object target, Object[] providedArgs,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParams)
at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
我已经将我的问题上传到 Youtube 这里是 link:
这是我在 Dropbox 中的项目 link:
我找到了解决办法 :) 非常感谢 Mr.Nick.McDermaid ......
解决方案是:
更改安全性较低的应用的帐户访问权限https://support.google.com/accounts/answer/6010255
我正在使用 SSIS 12、SQL Server 2012、Visual Studio 2012 和 .net 4。
我的SSIS脚本任务代码(发送邮件):
// Introduction to the script task
/* The Script Task allows you to perform virtually any operation that can be accomplished in
* a .Net application within the context of an Integration Services control flow.
*
* Expand the other regions which have "Help" prefixes for examples of specific ways to use
* Integration Services features within this script task. */
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
namespace ST_20fdf0b00e2949fda158e6680c127473
{
public void Main()
{
SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential("raihanuahmed@gmail.com", "password");
MailMessage msg = new MailMessage();
msg.From = new MailAddress("raihanuahmed@gmail.com");
msg.To.Add(new MailAddress("raihan.csse.aiub@gmail.com"));
msg.Subject = "AW2012 ETL Process Complite";
msg.Body = string.Format("{0} records loaded into DimProduct", 0);
smtp.Send(msg);
Dts.TaskResult = (int)ScriptResults.Success;
}
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
}
}
执行此电子邮件发送脚本后,我总是收到
"DTS Script :Runtime Error"
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
我已经将我的问题上传到 Youtube 这里是 link:
这是我在 Dropbox 中的项目 link:
我找到了解决办法 :) 非常感谢 Mr.Nick.McDermaid ...... 解决方案是:
更改安全性较低的应用的帐户访问权限https://support.google.com/accounts/answer/6010255