I had a similar problem, but I want to had a screenshot to help debug these cases : After closing the cryptic error prompt, watch into your debug output, there will be a short yet more useful error message : [
SSIS Script Task Help!!
Error
en System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
en System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
en System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
en System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
en Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
Code to send email
public void Main()
{
// TODO: Add your code here
MailMessage msg = new MailMessage("odalismiriam15@Stuff .com", "alavajessibel@Stuff .com"
, "Confirmación de migración de paquetes"
, "Se ha realizado con exito la ejecucion de paquetes de migración");
SmtpClient client = new SmtpClient("smtp.gmail.com", 25);
client.EnableSsl = true;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Credentials = new NetworkCredential("odalismiriam@Stuff .com", "**********");
client.Send(msg);
Dts.TaskResult = (int)ScriptResults.Success;
}
3 answers
Sort by: Newest
-
-
Michael Taylor 48,486 Reputation points
2022-05-19T20:37:18.223+00:00 Set
UseDefaultCredentials
to false before you set theCredentials
property.The port number doesn't seem correct for gmail. Verify in their docs.
Wrap the code in a try-catch and grab the exception so you get the actual error message. A stack trace isn't useful here, the underlying error is.
public void Main() { try { MailMessage msg = new MailMessage("odalismiriam15@gmail.com", "alavajessibel@gmail.com" SmtpClient client = new SmtpClient("smtp.gmail.com", 25); client.EnableSsl = true; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential("odalismiriam@gmail.com", "**"); client.Send(msg); Dts.TaskResult = (int)ScriptResults.Success; } catch (Exception e) { Dts.Events.FireError(0, "Error", e.Message, null, 0); Dts.TaskResult = (int)ScriptResults.Failure; }; }
-
Yitzhak Khabinsky 24,946 Reputation points
2022-05-19T20:09:20.173+00:00 Hi @Odalis Reina ,
gmail is using completely different ports: 465 or 587.
Check it out here: gmail-email-settingsAnd your entire c# code is very questionable.
No subject, no body, etc.