예제 #1
0
        private void SendAndDispose(List <MailItem> phishEmails)
        {
            MailItem reportEmail = null;

            try
            {
                reportEmail = (MailItem)Globals.ThisAddIn.Application.CreateItem(OlItemType.olMailItem);
                foreach (var phishEmail in phishEmails)
                {
                    reportEmail.Attachments.Add(phishEmail, OlAttachmentType.olEmbeddeditem);
                }

                reportEmail.Subject = Config.ReportingEmailSubject.Replace("$PluginName$", AppInfo.ApplicationProduct);
                reportEmail.To      = Config.SecurityTeamEmail;
                reportEmail.Body    = _reportEmailBody;

                reportEmail.Send();

                foreach (var phishEmail in phishEmails)
                {
                    phishEmail.Delete();
                }
            }
            finally
            {
                reportEmail.Dispose();
                foreach (var phishEmail in phishEmails)
                {
                    phishEmail.Dispose();
                }
            }
        }