Пример #1
0
        /// <summary>
        /// Forward mail for delegation. All (To) recipients of the original mail and the sender will be in (CC).
        /// </summary>
        /// <param name="outlook"></param>
        /// <param name="mail"></param>
        public static void Delegate(this Application outlook, MailItem mail)
        {
            var forwardMail = mail.Forward();

            forwardMail.Body = @"Hallo,

bitte beantworten.

Freundliche Grüße,

Andreas" + forwardMail.Body;

            var ownAddress = outlook.Session.CurrentUser.Address;

            foreach (Recipient r in mail.Recipients)
            {
                if (r.Type == (int)OlMailRecipientType.olTo && !(string.Equals(ownAddress, r.Address)))
                {
                    var nr = forwardMail.Recipients.Add(r);
                    nr.Type = (int)OlMailRecipientType.olCC;
                }
            }

            {
                var originalSender = forwardMail.Recipients.Add(mail.Sender);
                originalSender.Type = (int)OlMailRecipientType.olCC;
            }

            var inspector = (Inspector)outlook.Inspectors.Add(forwardMail);

            inspector.Activate();
        }
        private void AutoReply(string priority, MailItem currentMail)
        {
            if (priority == "P4")
            {
                var newMail = currentMail.Forward();
                newMail.Subject = "Testing";
                newMail.To      = "*****@*****.**";
                string contents = "hi, this is forward test <br/> <br/>";
                newMail.HTMLBody = contents + newMail.HTMLBody;

                newMail.Save();
                Log.Information($"Classify as Critial Mail, execute auto reply to {newMail.To}.");
            }
        }
        public async override Task RunCommand(object sender)
        {
            var      engine    = (IAutomationEngineInstance)sender;
            MailItem vMailItem = (MailItem)await v_MailItem.EvaluateCode(engine);

            var vRecipients = (List <string>) await v_Recipients.EvaluateCode(engine);

            MailItem newMail = vMailItem.Forward();

            foreach (var recipient in vRecipients)
            {
                newMail.Recipients.Add(recipient);
            }

            newMail.Recipients.ResolveAll();
            newMail.Send();
        }
Пример #4
0
        public override void RunCommand(object sender)
        {
            var      engine    = (AutomationEngineInstance)sender;
            MailItem vMailItem = (MailItem)v_MailItem.ConvertUserVariableToObject(engine);

            var vRecipients     = v_Recipients.ConvertUserVariableToString(engine);
            var splitRecipients = vRecipients.Split(';');

            MailItem newMail = vMailItem.Forward();

            foreach (var recipient in splitRecipients)
            {
                newMail.Recipients.Add(recipient.ToString().Trim());
            }

            newMail.Recipients.ResolveAll();
            newMail.Send();
        }
Пример #5
0
        public override void RunCommand(object sender)
        {
            var engine        = (Engine.AutomationEngineInstance)sender;
            var vSourceFolder = v_SourceFolder.ConvertToUserVariable(sender);
            var vFilter       = v_Filter.ConvertToUserVariable(sender);
            var vRecipients   = v_Recipients.ConvertToUserVariable(sender);

            var splittext = vRecipients.Split(';');

            Application  outlookApp  = new Application();
            AddressEntry currentUser = outlookApp.Session.CurrentUser.AddressEntry;
            NameSpace    test        = outlookApp.GetNamespace("MAPI");

            if (currentUser.Type == "EX")
            {
                MAPIFolder inboxFolder   = test.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Parent;
                MAPIFolder sourceFolder  = inboxFolder.Folders[vSourceFolder];
                Items      filteredItems = null;

                if (vFilter != "")
                {
                    filteredItems = sourceFolder.Items.Restrict(vFilter);
                }
                else
                {
                    filteredItems = sourceFolder.Items;
                }

                foreach (object _obj in filteredItems)
                {
                    if (_obj is MailItem)
                    {
                        MailItem tempMail = (MailItem)_obj;
                        MailItem newMail  = tempMail.Forward();
                        foreach (var t in splittext)
                        {
                            newMail.Recipients.Add(t.ToString().Trim());
                        }
                        newMail.Recipients.ResolveAll();
                        newMail.Send();
                    }
                }
            }
        }
Пример #6
0
        private void TrainWithForward(Boolean isSpam, MailItem mi)
        {
            DateTime dtBegin = DateTime.Now;
            String   s       = "";

            if (isSpam)
            {
                s = this.config.ForwardForSpam;
            }
            else
            {
                s = this.config.ForwardForHam;
            }

            this.logger.WriteLine("send mail to '" + s + "'....");

            MailItem miF = mi.Forward();

            miF.Recipients.Add(s);
            miF.Recipients.ResolveAll();
            miF.Send();

            this.logger.WriteLine("done, forward took " + (DateTime.Now - dtBegin).TotalSeconds + " seconds.");
        }
Пример #7
0
        private void TrainWithForward(Boolean isSpam, MailItem mi)
        {
            DateTime dtBegin = DateTime.Now;
            String s = "";

            if (isSpam)
            {
                s = this.config.ForwardForSpam;
            }
            else
            {
                s = this.config.ForwardForHam;
            }

            this.logger.WriteLine("send mail to '" + s + "'....");

            MailItem miF = mi.Forward();
            miF.Recipients.Add(s);
            miF.Recipients.ResolveAll();
            miF.Send();

            this.logger.WriteLine("done, forward took " + (DateTime.Now - dtBegin).TotalSeconds + " seconds.");
        }