using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
namespace ST_41027be1cfb14c29a9b05c97e79b0f8c.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 msg = new MailMessage ("cxulz@hotmail.com","cxulz@hotmail.com", "This from C#","hey, buddy");
SmtpClient client =new SmtpClient ("smtp.live.com",587);
client.EnableSsl =true;
client.DeliveryMethod =SmtpDeliveryMethod.Network;
client.Credentials =new NetworkCredential("cxulz@hotmail.com","xxxxxxx1");
client.Send(msg);
Dts.TaskResult = (int)ScriptResults.Success;
}
}
}
================
see the differences with the VB codes for the same functionality
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Net
Imports System.Net.Mail
Partial Public Class ScriptMain
Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
Enum ScriptResults
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
End Enum
Public Sub Main()
Dim msg As New MailMessage("cxulz@hotmail.com", "cxulz@hotmail.com", "This from VB", "hey, buddy")
Dim client As New SmtpClient("smtp.live.com", 587)
client.EnableSsl = True
client.DeliveryMethod = SmtpDeliveryMethod.Network
client.Credentials = New NetworkCredential("cxulz@hotmail.com", "nanjing1")
client.Send(msg)
Dts.TaskResult = ScriptResults.Success
End Sub
End Class