• 有参数的程序,可以被调用


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows.Forms;
    using System.IO;
    
    namespace SendMail
    {
        static class Program
        {
            /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main(string[] Arrs)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
               //Application.Run(new Form1());
                if (Arrs == null) { WriteErr("No Parameter"); return; }
    
                string sfrom = "";
                string sto = "";
                string scc = "";
                string sbcc = "";
                string ssubject = "";
                string sbody = "";
                string satt = "";
                string[] Arr = Arrs[0].Split('|');
                if (Arr.Length > 0)
                    sfrom = Arr[0];
                if (Arr.Length > 1)
                    sto = Arr[1];
                if (Arr.Length > 2)
                    scc = Arr[2];
                if (Arr.Length > 3)
                    sbcc = Arr[3];
                if (Arr.Length > 4)
                    ssubject = Arr[4];
                if (Arr.Length > 5)
                    sbody = Arr[5];
                if (Arr.Length > 6)
                    satt = Arr[6];
                if (sfrom == "" || (sto == "" && scc == "")) { WriteErr("Parameter Error"); return; }
    
                SendMail.Mail SendMail = new SendMail.Mail();
                string Err = SendMail.SendMail(sfrom, sto, scc, sbcc, ssubject, sbody, satt);
                WriteErr(Err);
            }
    
            static void WriteErr(string strErr)
            {
                if (strErr == "") return;
                System.IO.StreamWriter sw;
                sw = new StreamWriter(Application.StartupPath + "\Error.err", false, System.Text.Encoding.Default);
                sw.WriteLine(strErr);
                sw.Flush();
                sw.Close();
            }
        }
    }
  • 相关阅读:
    UI层复习笔记
    async 的三大返回类型
    用scikit-learn进行LDA降维
    关于解决python线上问题的几种有效技术
    ASP.NET Core MVC/WebAPi 模型绑定探索
    浅谈 Fragment 生命周期
    vue2.0实践的一些细节
    Linux----------Mysql死锁
    Linux----------容器docker file
    Linux----------常用容器命令
  • 原文地址:https://www.cnblogs.com/vinsonLu/p/3656994.html
Copyright © 2020-2023  润新知