Script Task – Ejercicio enviando E-Mail desde SMTP Externo
1. Agregar 4 variables como se muestran a continuación (debes especificar los valores de tu
entorno):
2. Dentro del control flow agregar un componente Script Task y configurarlo del siguiente modo:
a. Asignar las variables creadas al script component como variables de lectura
b. Hacer click en el botón Edit Script…:
3. Editar el script para que quede como se muestra a continuación:
Los datos de conexión deben ser tomados de tu proveedor de correo.
La contraseña fue eliminada de la imagen por temas de seguridad.
Si quieres copiar y pegar el script acá lo dejo:
#region Help: 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. */
#endregion
#region Namespaces
using System;
using [Link];
#endregion
namespace ST_d2129e205b39412ababd2f16329bec5c
{
[[Link]]
public partial class ScriptMain : [Link]
{
public void Main()
{
String destinatario = [Link]["Destinatario"].[Link]();
String remitente = [Link]["Remitente"].[Link]();
String asunto = [Link]["Asunto"].[Link]();
String cuerpo = [Link]["Cuerpo"].[Link]();
MailMessage miCorreo = new MailMessage(remitente, destinatario, asunto, cuerpo);
[Link] = true;
SmtpClient clienteSMTP = new SmtpClient("[Link]", 587);
[Link] = true;
[Link] = false;
[Link] = new [Link]("elopez@[Link]", "Contraseña*");
[Link](miCorreo);
[Link] = (int)[Link];
}
#region ScriptResults declaration
enum ScriptResults
{
Success = [Link],
Failure = [Link]
};
#endregion
}
}