Hi @Odalis Reina ,
gmail is using completely different ports: 465 or 587.
Check it out here: gmail-email-settings
And your entire c# code is very questionable.
No subject, no body, etc.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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;
}
Hi @Odalis Reina ,
gmail is using completely different ports: 465 or 587.
Check it out here: gmail-email-settings
And your entire c# code is very questionable.
No subject, no body, etc.
Set UseDefaultCredentials
to false before you set the Credentials
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;
};
}
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 : [