I have put together a super simple script to fire off an email as the last step of an ssis package. The script compiles and runs just fine when I build it in a c# environment. When I use the ssis script editor and copy/paste the thing over I get the following error trying to build it:
Error: Program Using Top-Level Statements Must Be An Executable
using System;
using System.Net.Mail;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
client.EnableSsl = true;
client.Credentials = new System.Net.NetworkCredential("testEmail", "Pa55");
MailAddress from = new MailAddress("testEmail1", String.Empty, System.Text.Encoding.UTF8);
MailAddress to = new MailAddress("testEmail2");
MailMessage message = new MailMessage(from, to);
message.Body = "This is your body message";
message.BodyEncoding = System.Text.Encoding.UTF8;
message.Subject = "Subject";
message.SubjectEncoding = System.Text.Encoding.UTF8;
client.Send(message);
Is there something I am missing when trying to build this as a script in my ssis package?
question from:
https://stackoverflow.com/questions/65888622/error-program-using-top-level-statements-must-be-an-executable 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…