Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
482 views
in Technique[技术] by (71.8m points)

c# - Error: Program Using Top-Level Statements Must Be An Executable

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...