SQL Server 2012 SSIS脚本将邮件从Gamil发送到Gmail的任务,显示“DTS脚本:运行时错误” [英] SQL Server 2012 SSIS Script Task for sending mail from Gamil to Gmail , showing "DTS Script :Runtime Error"
问题描述
我的SSIS脚本任务代码(用于发送邮件):
//脚本任务简介
/ *脚本任务允许您执行几乎任何可以在
* a .Net应用程序在Integration Services控制流程的上下文中。
*
*展开具有帮助前缀的其他区域,以便在此脚本任务中使用
* Integration Services功能的特定方法。 * /
使用系统;
使用System.Data;
使用Microsoft.SqlServer.Dts.Runtime;
使用System.Windows.Forms;
使用System.Net;
使用System.Net.Mail;
命名空间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,密码);
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}记录加载到DimProduct,0);
smtp.Send(msg);
Dts.TaskResult =(int)ScriptResults.Success;
}
枚举ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts。 Runtime.DTSExecResult.Failure
};
}
}
执行此电子邮件发送脚本后,我总是得到
DTS脚本:运行时错误
在System.RuntimeMethodHandle.InvokeMethod (Object object,Object []
arguments,Signature sig,Boolean constructor)
在System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,
Object [] parameters,Object []参数)
在System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags
invokeAttr,Binder binder,Object []参数,CultureInfo文化)
在System.RuntimeType .InvokeMember(String name,BindingFlags
bindingFlags,Binder binder,Object target,Object [] providedArgs,
ParameterModifier []修饰符,CultureInfo文化,String []
namedParams)
在Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
我已经上传我的问题到Youtube这里是链接:
这是Dropbox中的项目链接:
我找到了解决方案:)很多谢谢Mr.Nick.McDermaid ......
解决方案是:
更改安全性较低的应用的帐户访问权限 https://support.google。 com / accounts / answer / 6010255
I am using SSIS 12, SQL Server 2012, Visual Studio 2012 and .net 4.
My SSIS script task code(for sending mail):
// 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
};
}
}
After executing this email sending script, I am always getting
"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()
I have uploaded my problem into Youtube here is the link:
Here is my project link in Dropbox:
I have found the solution :) Many Many thanks to Mr.Nick.McDermaid ...... solution is :
Change account access for less secure apps https://support.google.com/accounts/answer/6010255
这篇关于SQL Server 2012 SSIS脚本将邮件从Gamil发送到Gmail的任务,显示“DTS脚本:运行时错误”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!