Beispiel #1
0
        public static void sendEmail(Dictionary <String, String> args)
        {
            var oApp = new Outlook.Application();
            var oNS  = MailStoreProcessor.logOn(oApp);
            IEnumerable <Tuple <string, string, bool?> > rows = null;

            switch (args.GetValueOrDefault("content"))
            {
            case "json": rows = DataTools.JsonToDict(args["text"]).Select(e => new Tuple <string, string, bool?>(e.Key, e.Value, null)); break;

            case "comma": rows = args["text"]?.Split(",")?.Select(e => new Tuple <string, string, bool?>("", e, null)); break;
            }
            new EmailResponseController().execute(null, new EmailResponseConfig()
            {
                attachments = DataTools.getYamlArray(args.GetValueOrDefault("attachments")).ToArray(), oApp = oApp, template = args.ContainsKey("template")?new FileInfo(args["template"]):null, sentonbehalf = args.GetValueOrDefault("sentonbehalf") ?? ConfigurationManager.Configuration["DefaultSenderAddress"], emailSubject = args.GetValueOrDefault("subject"), ResultMap = args.ContainsKey("resultMap") ? ConfigTools.YamlToDict(args["resultMap"]) : null, rows = rows, defaultMessage = args["text"], replyRecipients = args["recipients"].Split(";")
            });
            Logger.WriteToConsole($"Sending response success template for  [{args["subject"]}]");



            if (oNS != null)
            {
                oNS.Logoff();
                Marshal.ReleaseComObject(oNS);
            }
            if (oApp != null)
            {
                Marshal.ReleaseComObject(oApp);
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }