1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| using System.Net.Mail;
using System.Net;
using System;
using System.IO;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
namespace ST_b88226a71961424cadf01e18c7537654.csproj
{
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion
public void Main()
{
MailMessage myHtmlMessage;
SmtpClient mySmtpClient;
String body = "Corps du mail";
String destinataire= "Abdallah.mehdoini@sagemcom.com";
String expediteur = "Abdallah.mehdoini@sagemcom.com";
String objet = "Objet";
String smtp = "xx.xx.xx..Xx";
String mdp_smtp = "mdp smtp";
String id_smtp = expediteur;
// Pour passer des variables provenant du flux
//body = (Dts.Variables.Add("vMSG_Body,true,User,3″)).ToString();
//adresseMail = (Dts.Variables.Add("vMSG_Mail, true, "User, "3)).ToString();
myHtmlMessage = new MailMessage(expediteur, destinataire, objet, body) ;
mySmtpClient = new SmtpClient(smtp, 25) ; //(ou 587)
mySmtpClient.EnableSsl = false ;
mySmtpClient.Credentials = new System.Net.NetworkCredential(id_smtp, mdp_smtp) ;
mySmtpClient.Send(myHtmlMessage) ;
Dts.TaskResult = (int)ScriptResults.Success;
}
}
} |
Partager