public async override Task RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; MailItem vMailItem = (MailItem)await v_MailItem.EvaluateCode(engine); var vDestinationFolder = (string)await v_DestinationFolder.EvaluateCode(engine); Application outlookApp = new Application(); NameSpace test = outlookApp.GetNamespace("MAPI"); test.Logon("", "", false, true); AddressEntry currentUser = outlookApp.Session.CurrentUser.AddressEntry; if (currentUser.Type == "EX") { MAPIFolder inboxFolder = (MAPIFolder)test.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Parent; MAPIFolder destinationFolder = inboxFolder.Folders[vDestinationFolder]; if (v_OperationType == "Move MailItem") { if (v_MoveCopyUnreadOnly == "Yes") { if (vMailItem.UnRead == true) { vMailItem.Move(destinationFolder); } } else { vMailItem.Move(destinationFolder); } } else if (v_OperationType == "Copy MailItem") { MailItem copyMail; if (v_MoveCopyUnreadOnly == "Yes") { if (vMailItem.UnRead == true) { copyMail = (MailItem)vMailItem.Copy(); copyMail.Move(destinationFolder); } } else { copyMail = (MailItem)vMailItem.Copy(); copyMail.Move(destinationFolder); } } } }
public override void RunCommand(object sender) { var engine = (IAutomationEngineInstance)sender; MailItem vMailItem = (MailItem)v_MailItem.ConvertUserVariableToObject(engine, nameof(v_MailItem), this); var vDestinationFolder = v_DestinationFolder.ConvertUserVariableToString(engine); Application outlookApp = new Application(); AddressEntry currentUser = outlookApp.Session.CurrentUser.AddressEntry; NameSpace test = outlookApp.GetNamespace("MAPI"); if (currentUser.Type == "EX") { MAPIFolder inboxFolder = (MAPIFolder)test.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Parent; MAPIFolder destinationFolder = inboxFolder.Folders[vDestinationFolder]; if (v_OperationType == "Move MailItem") { if (v_MoveCopyUnreadOnly == "Yes") { if (vMailItem.UnRead == true) { vMailItem.Move(destinationFolder); } } else { vMailItem.Move(destinationFolder); } } else if (v_OperationType == "Copy MailItem") { MailItem copyMail = null; if (v_MoveCopyUnreadOnly == "Yes") { if (vMailItem.UnRead == true) { copyMail = (MailItem)vMailItem.Copy(); copyMail.Move(destinationFolder); } } else { copyMail = (MailItem)vMailItem.Copy(); copyMail.Move(destinationFolder); } } } }
private void MailItemAction(MailItem currentMail) { var subjectCategory = currentMail.Subject.Substring(0, 8); if (subjectCategory == "Incident") { var priority = currentMail.Subject.Substring(9, 2); var incidentCateogty = GetIncidentCategory(priority); string incidentNumber; switch (incidentCateogty) { case "IncidentWithPriority": MoveToFolder(priority, currentMail); AutoReply(priority, currentMail); incidentNumber = currentMail.Subject.Substring(12, 10); RecordIncidentNumberIntoSqliteDb(incidentNumber, priority); break; case "CommandOrIncidentWithoutPriority": incidentNumber = currentMail.Subject.Substring(9, 10); priority = GetPriorityFromDb(incidentNumber); MoveToFolder(priority, currentMail); break; } } else { Log.Information($"Not incident notice, move mail:{currentMail.Subject} to Otherd folder."); currentMail.Move(OthersFolder); } }
public void SendMail(MailItem mailItem) { if (mailItem.FlagRequest == MailServiceSettings.CopyMailFlag) { MAPIFolder folder = _Application.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail); mailItem.Move(folder); return; } if (mailItem.FlagRequest != MailServiceSettings.AutoMailFlag) { string to = $"{mailItem.To}; {mailItem.CC}"; Outlook.Folder selectedFolder = StartDialogService(); if (selectedFolder != null) { mailItem.SaveSentMessageFolder = selectedFolder; mailItem.Save(); MailItem copyMail = mailItem.Copy(); copyMail.FlagRequest = MailServiceSettings.CopyMailFlag; copyMail.Save(); SendToRecipients(to); } } mailItem.Send(); }
public void Move(Folder folder) { if (!GetParent().Name.Equals(folder.Name)) { _item.Move(folder); } }
public override bool Execute(MailItem item) { MAPIFolder folder = null; item.Move(DestinationFolder); return(true); }
public void AddMailItems(MailItem mailItem, string folderName = "") { folderName = folderName ?? "Temp_" + PSTName; MAPIFolder destFolder = GetFolder(folderName); MailItem tempMailItem = mailItem.Copy(); tempMailItem.Move(destFolder); }
/// <summary> /// Deletes the email from which the subject is passed in within the specified folder. /// Attention: The subject mustn't contain any special chars. /// </summary> private void TryDeleteEmailPermanentyFromFolder(MailItem mailItem) { Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application(); NameSpace outlookNs = app.Application.GetNamespace("MAPI"); mailItem.Subject = "phishing"; mailItem.Move(outlookNs.GetDefaultFolder(OlDefaultFolders.olFolderDeletedItems)); mailItem.Delete(); Marshal.ReleaseComObject(mailItem); }
public string IncomeMail(MailItem mailItem) { mailItem.UnRead = true; mailItem.Save(); Outlook.Folder selectedFolder = StartDialogService(); if (selectedFolder != null) { MailItem copyMail = mailItem.Copy(); copyMail.Move(selectedFolder); } return(mailItem.EntryID); }
/* public void cleanupSent() { * * } */ //sort by recive date -inbox //sort by sent date - Sent Items public void copyEmails(string fromFolderName, string toFolderName, int mailCount) { MAPIFolder fromFolder = getfolder(fromFolderName); MAPIFolder toFolder = getfolder(toFolderName); Items fromMessages = fromFolder.Items; for (int i = 1; i <= mailCount; i++) { MailItem message = fromMessages[i] as MailItem; MailItem copiedmessage = message; copiedmessage.Move(toFolder); } }
private void MoveToFolder(string priority, MailItem currentMail) { if (priority == "P4") { currentMail.Move(IncidentsCriticalFolder); var folderName = "IncidentCritial Folder"; Log.Information($"Move mail:{currentMail.Subject} to {folderName}."); } if (priority == "P5") { currentMail.Move(IncidentsNormalFolder); var folderName = "IncidentNormal Folder"; Log.Information($"Move mail:{currentMail.Subject} to {folderName}."); } if (priority == "NoDefined") { currentMail.Move(OthersFolder); var folderName = "Others Folder"; Log.Information($"Cannot recognize priority, move mail:{currentMail.Subject} to {folderName}."); } }
private bool ReplyViaOutlook(EmailConfiguration emailConfig) { ClientConfiguration.EmailSettings config = Program.Configuration.Email; try { Items folderItems = _folderSent.Items; foreach (MailItem folderItem in folderItems) { if (folderItem.UnRead) { EmailReplyManager emailReply = new EmailReplyManager(); folderItem.HTMLBody = $"{emailReply.Reply} {Environment.NewLine}{Environment.NewLine}ORIGINAL MESSAGE --- {Environment.NewLine}{Environment.NewLine}{folderItem.Body}"; folderItem.Subject = $"RE: {folderItem.Subject}"; MailItem replyMail = folderItem.Reply(); replyMail.Move(_folderSent); SafeMailItem rdoMail = new Redemption.SafeMailItem { Item = replyMail }; rdoMail.Recipients.ResolveAll(); rdoMail.Send(); var mapiUtils = new Redemption.MAPIUtils(); mapiUtils.DeliverNow(0, 0); if (config.SetForcedSendReceive) { _log.Trace("Forcing mapi - send and receive"); _oMapiNamespace.SendAndReceive(false); Thread.Sleep(3000); } return(true); } } } catch (Exception e) { _log.Error($"Outlook reply error: {e}"); } return(false); }
public static void MoveMessage(MailMessage message, string folderPath, string account) { MAPIFolder folder = GetFolder(folderPath, account); if (folder == null) { throw new ArgumentException("找不到目录"); } string text = message.Headers["Uid"]; if (string.IsNullOrEmpty(text)) { throw new ArgumentException("非法邮件消息"); } MailItem mailItem = null; MailItem mailItem2 = null; Application application = null; try { application = InitOutlook(); mailItem = (dynamic)application.Session.GetItemFromID(text, Type.Missing); if (mailItem != null) { mailItem2 = (mailItem.Move(folder) as MailItem); mailItem2.Save(); } } finally { if (folder != null) { Marshal.ReleaseComObject(folder); } if (mailItem != null) { Marshal.ReleaseComObject(mailItem); } if (mailItem2 != null) { Marshal.ReleaseComObject(mailItem2); } if (application != null) { Marshal.ReleaseComObject(application); } } }
private static void _ParseOrder(MailItem item) { if (item.SenderEmailAddress == OrderTypeInfo.WufooSenderEmail) { } if (item.SenderEmailAddress == OrderTypeInfo.MagentoSenderEmail) { _ReformatDate(item); bool toBeProcessed = Magento.ParseOrder(item.HTMLBody); if (!toBeProcessed) { item.UnRead = false; UserProperty parsed = item.UserProperties.Add(UserPropertyNames.PARSED, OlUserPropertyType.olText, true); DisableVisiblePrintUserProp(parsed); item.Move(DeletedItems); } } }
public void SendReport(MailItem reportedMailItem) { Helpers.SetUserProperty(reportedMailItem, Constants.EMAIL_REPORTED, true); Helpers.SetUserProperty(reportedMailItem, Constants.EMAIL_REPORTED_DATE, DateTime.Now); reportedMailItem.Save(); CreateAndSendReport(reportedMailItem); if (Configuration.DeleteAfterReport) { reportedMailItem.Delete(); } else if (Configuration.MoveToJunkAfterReport) { MAPIFolder junkFolder = Application.ActiveExplorer().Session.GetDefaultFolder(OlDefaultFolders.olFolderJunk); reportedMailItem.Move(junkFolder); } }
private void HandleMail(EmailType emailType, MailItem phishEmail) { switch (emailType) { case EmailType.Spam: var spamDialogReslut = MessageBox.Show(TextHelper.SpamAddedText(lang), Resources.MessageBox_Title, MessageBoxButtons.OKCancel); if (spamDialogReslut == DialogResult.OK) { phishEmail.Move(Globals.ThisAddIn.GetSpamFolder()); Globals.ThisAddIn.CreateJunkRule(phishEmail.SenderEmailAddress); } break; case EmailType.Phishing: MailItem reportEmail = Globals.ThisAddIn.Application.CreateItem(OlItemType.olMailItem); string subject = PhishReporterConfig.ReportEmailSubject + " - " + phishEmail.Subject + " - " + new Random().Next(1000, 9999); reportEmail.Attachments.Add(phishEmail, OlAttachmentType.olEmbeddeditem); reportEmail.Subject = subject; reportEmail.To = PhishReporterConfig.SecurityTeamEmailAlias; reportEmail.Body = "This is a user-submitted report of a phishing email delivered by the PhishReporter Outlook plugin. Please review the attached phishing email"; reportEmail.Send(); // Delete Mail Permanently string phishSubject = phishEmail.Subject; phishEmail.Delete(); DeleteEmailFromFolder(phishSubject, OlDefaultFolders.olFolderDeletedItems); MessageBox.Show(TextHelper.ThankYouMessage(lang), Resources.MessageBox_Title, MessageBoxButtons.OK); // Delete Sent Mail DeleteEmailFromFolder(subject, OlDefaultFolders.olFolderSentMail); DeleteEmailFromFolder(subject, OlDefaultFolders.olFolderDeletedItems); break; case EmailType.None: //MessageBox.Show(TextHelper.NoEmailSelectedText(lang), Resources.MessageBox_Title, MessageBoxButtons.OK); break; } }
private void AfterTraining_Ham(MailItem mi) { if (this.config.AfterTraining_Ham_DoDelete) { // delete mail mi.Delete(); } else { // mark as read if (this.config.AfterTraining_Ham_MarkAsRead) { mi.UnRead = false; mi.Save(); } // prefix - it's ham, so remove the prefix if (this.config.AfterTraining_Ham_DoPrefix) { // mi.Subject = this.config.AfterTraining_Ham_PrefixWith + " " + mi.Subject; mi.Subject = mi.Subject.Replace(this.config.AfterTraining_Ham_PrefixWith, ""); mi.Save(); } // move if (this.config.AfterTraining_Ham_DoMove) { if (this.config.AfterTraining_Ham_MoveTo != "") { mi.Move(this.mailparser.getFolderByName(this.config.AfterTraining_Ham_MoveTo)); } } else { // do nothing } } }
private static bool _SetupTestEnvironment(Folder itemSourceFolder, Folder parentFolder, string testFolderName, int maxItems, string sourceItemFilter = null) { if (_testSetup) { return(true); } Trace.WriteLine($"Begin setup test folder and populate with {maxItems} item(s)"); if (sourceItemFilter != null) { Trace.WriteLine($"\t - and apply filter {sourceItemFilter}"); } if (itemSourceFolder.Items.Count == 0) { Trace.WriteLine("No valid items in source folder. Try another folder."); return(false); } Items FilteredItems = itemSourceFolder.Items; if (sourceItemFilter != null) { try { FilteredItems = itemSourceFolder.Items.Restrict(sourceItemFilter); Trace.WriteLine("Filter successful"); } catch (System.Exception e) { Trace.WriteLine("Failed to filter items, " + e.Message); return(false); } } ; _testFolderParent = parentFolder; TestFolder = parentFolder.GetFolder(testFolderName); bool alreadyExists = false; if (TestFolder != null) { alreadyExists = true; } else { TestFolder = (Folder)parentFolder.Folders.Add(testFolderName); while (TestFolder == null) { Thread.Sleep(200); } ; } Trace.WriteLine($"Folder already exists: {alreadyExists}"); _testItems = new List <MailItem>(); List <MailItem> itemsToBeDuplicated = new List <MailItem>(); maxItems = (maxItems > FilteredItems.Count) ? FilteredItems.Count : maxItems; Trace.WriteLine($"maxItems set to {maxItems}"); if (alreadyExists) { foreach (MailItem item in TestFolder.Items) { _testItems.Add(item); } if (_testItems.Count > maxItems) { return(true); } } TestFolder.ShowItemCount = OlShowItemCount.olShowTotalItemCount; int i = 1; while (itemsToBeDuplicated.Count < maxItems) { itemsToBeDuplicated.Add((MailItem)FilteredItems[i]); i++; } try { foreach (MailItem item in itemsToBeDuplicated) { MailItem copy = (MailItem)item.Copy(); copy.UnRead = false; _testItems.Add(copy); copy.Move(TestFolder); } Trace.WriteLine("\t Complete"); _testSetup = true; return(true); } catch { Trace.WriteLine("\t Failed"); return(false); } }
public override void RunCommand(object sender) { var engine = (Engine.AutomationEngineInstance)sender; var vSourceFolder = v_SourceFolder.ConvertToUserVariable(sender); var vFilter = v_Filter.ConvertToUserVariable(sender); var vDestinationFolder = v_DestinationFolder.ConvertToUserVariable(sender); 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]; MAPIFolder destinationFolder = inboxFolder.Folders[vDestinationFolder]; 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; if (v_OperationType == "Move Emails") { if (v_MoveUnreadOnly == "Yes") { if (tempMail.UnRead == true) { tempMail.Move(destinationFolder); } } else { tempMail.Move(destinationFolder); } } else if (v_OperationType == "Copy Emails") { MailItem copyMail = null; if (v_MoveUnreadOnly == "Yes") { if (tempMail.UnRead == true) { copyMail = tempMail.Copy(); copyMail.Move(destinationFolder); } } else { copyMail = tempMail.Copy(); copyMail.Move(destinationFolder); } } } } } }
/// <summary> /// This method scans a single mail item against all criteria to determine if the mail item needs to be moved. /// If so then it moves the mail item to the specified target outlook folder for the first set of criteria that it matches. /// </summary> private bool ScanAll(_NameSpace nameSpace, MailItem mailItem, string sender, string subject, string body, ref int movedItemsCount, out bool anyCriteriaApplied) { bool anyPasses = false; anyCriteriaApplied = false; SignalBeginScan(Administrator.ProfileManager.UserSettings.Entries.Count); foreach (var pair in Administrator.ProfileManager.UserSettings.Entries) { if (Interrupt.Reason != "Cancel") { SignalUpdateScan(1); bool criteriaDisplayed = false; UserSetting userSetting = pair.Value; string[] parts = userSetting.Folder.Split(Path.DirectorySeparatorChar); MAPIFolder targetFolder = null; try { targetFolder = nameSpace.Folders[parts[0]]; for (int ptr = 1; ptr < parts.Length; ptr++) { targetFolder = targetFolder.Folders[parts[ptr]]; } } catch (System.Exception ex) { Administrator.Tracer.WriteTimedMsg("E", ex.Message); targetFolder = null; } if (targetFolder != null) { string fullPath = targetFolder.FullFolderPath; string shortPath = targetFolder.FolderPath; string name = targetFolder.Name; string senderCriteria = string.Empty; Scanner senderScanner = null; if (userSetting.SenderCriteria.Trim().Length > 0) { senderCriteria = Clean(userSetting.SenderCriteria); senderScanner = new Scanner(senderCriteria); } string subjectCriteria = string.Empty; Scanner subjectScanner = null; if (userSetting.SubjectCriteria.Trim().Length > 0) { subjectCriteria = Clean(userSetting.SubjectCriteria); subjectScanner = new Scanner(subjectCriteria); } string bodyCriteria = string.Empty; Scanner bodyScanner = null; if (userSetting.BodyCriteria.Trim().Length > 0) { bodyCriteria = Clean(userSetting.BodyCriteria); bodyScanner = new Scanner(bodyCriteria); } bool criteriaApplied = false; string prefix = string.Empty; bool pass = Scan(sender, subject, body, senderScanner, subjectScanner, bodyScanner, out criteriaApplied, out prefix); anyPasses |= pass; anyCriteriaApplied |= criteriaApplied; if (criteriaApplied && pass) { if (!criteriaDisplayed) { criteriaDisplayed = true; Administrator.Tracer.WriteLine(); Administrator.Tracer.WriteMsg("I", String.Format(@"Folder : ""{0}""", userSetting.Folder)); if (senderCriteria.Trim().Length > 0) { Administrator.Tracer.WriteTimedMsg("I", String.Format(@"Sender Criteria = {0}", senderCriteria)); } else { Administrator.Tracer.WriteTimedMsg("I", "Sender Criteria = None"); } if (subjectCriteria.Trim().Length > 0) { Administrator.Tracer.WriteTimedMsg("I", String.Format(@"Subject Criteria = {0}", subjectCriteria)); } else { Administrator.Tracer.WriteTimedMsg("I", "Subject Criteria = None"); } if (bodyCriteria.Trim().Length > 0) { Administrator.Tracer.WriteTimedMsg("I", String.Format(@"Body Criteria = {0}", bodyCriteria)); } else { Administrator.Tracer.WriteTimedMsg("I", "Body Criteria = None"); } Administrator.Tracer.WriteLine(); } Administrator.Tracer.WriteTimedMsg("I", String.Format(@"Matched [{0}] Moving -> Sender : ""{1}"", Subject : ""{2}""", prefix, sender, subject)); mailItem.Move(targetFolder); movedItemsCount++; //No need to check any further criteria as the mail item has already been matched to a preceding criteria and moved. break; } } } else { break; } } SignalEndOfScan(Administrator.ProfileManager.UserSettings.Entries.Count); return(anyPasses); }
/// <summary> /// Sends the selected emails using the specified profile /// </summary> /// <param name="profileID"></param> public static void SendReports(string profileID) { SpamGrabberCommon.Profile profile = new SpamGrabberCommon.Profile(profileID); if (profile.AskVerify) { if (MessageBox.Show("Are you sure you want to report the selected item(s)?", "Report messages", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } } Explorer exp = _app.Application.ActiveExplorer(); // Create a collection to hold references to the attachments List <string> attachmentFiles = new List <string>(); // Make sure at least one item is sent bool bItemsSelected = false; // First make sure the selected emails have been downloaded bool bNeedsSendReceive = false; for (int i = 1; i <= exp.Selection.Count; i++) { if (exp.Selection[i] is MailItem) { MailItem mail = (MailItem)exp.Selection[i]; bItemsSelected = true; // If the item has not been downloaded, mark for download if (mail.DownloadState == OlDownloadState.olHeaderOnly) { bNeedsSendReceive = true; mail.MarkForDownload = OlRemoteStatus.olMarkedForDownload; mail.Save(); } System.Runtime.InteropServices.Marshal.ReleaseComObject(mail); } } if (bNeedsSendReceive) { // Download the marked emails // TODO: Trying to carry on at this point returns blank email bodies. Try and find a way of downloading them properly. _app.Session.SendAndReceive(false); MessageBox.Show("One of more emails were not downloaded from the server. Please ensure they are now downloaded and click report again", "SpamGrabber", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (bItemsSelected) { // Now get references to all the items for (int i = 1; i <= exp.Selection.Count; i++) { if (exp.Selection[i] is MailItem) { MailItem mail = (MailItem)exp.Selection[i]; if (profile.UseRFC) { // Direct attaching seems to be buggy. Save the mailitem first string fileName = Path.Combine(Path.GetTempPath(), Path.GetTempFileName() + ".msg"); mail.SaveAs(fileName); attachmentFiles.Add(fileName); } else { // Create temp text file string fileName = Path.Combine(Path.GetTempPath(), Path.GetTempFileName() + ".txt"); TextWriter tw = new StreamWriter(fileName); tw.Write(GetMessageSource(mail, profile.CleanHeaders)); tw.Close(); attachmentFiles.Add(fileName); } System.Runtime.InteropServices.Marshal.ReleaseComObject(mail); } } // Are we using a single email or one per report? if (profile.SendMultiple) { // Create the report email MailItem reportEmail = CreateReportEmail(profile); // Attach the files foreach (string attachment in attachmentFiles) { reportEmail.Attachments.Add(attachment); } // Do we need to keep a copy? if (!profile.KeepCopy) { reportEmail.DeleteAfterSubmit = true; } // Send the report reportEmail.Send(); System.Runtime.InteropServices.Marshal.ReleaseComObject(reportEmail); } else { // Send one email per report foreach (string attachment in attachmentFiles) { MailItem reportEmail = CreateReportEmail(profile); reportEmail.Attachments.Add(attachment); // Do we need to keep a copy? if (!profile.KeepCopy) { reportEmail.DeleteAfterSubmit = true; } reportEmail.Send(); System.Runtime.InteropServices.Marshal.ReleaseComObject(reportEmail); } } // Sort out actions on the source emails for (int i = 1; i <= exp.Selection.Count; i++) { if (exp.Selection[i] is MailItem) { MailItem mail = (MailItem)exp.Selection[i]; if (profile.MarkAsReadAfterReport) { mail.UnRead = false; } if (profile.MoveToFolderAfterReport) { mail.Move(_app.GetNamespace("MAPI").GetFolderFromID( profile.MoveFolderName, profile.MoveFolderStoreId)); } if (profile.DeleteAfterReport) { mail.UnRead = false; mail.Delete(); } System.Runtime.InteropServices.Marshal.ReleaseComObject(mail); } } } }
private bool IsUpdateMessage(MailItem mail) { if (!mail.Subject.Equals(UPDATE_SUBJECT, StringComparison.CurrentCultureIgnoreCase)) return false; var folder = (Folder)mail.Parent; if (folder == null) return false; var store = Session.GetStoreFromID(folder.StoreID); Logger.Verbose("IsUpdateMessage", string.Format( "evaluating {0} in {1}\\{2}", mail.Subject, store.DisplayName, folder.Name)); if (!IsInOwnedStore(folder)) return false; //extract data from internet message header var pointer = ""; var sender = ""; var server = ""; var port = ""; Utils.ReadUpdateHeaders(mail, ref sender, ref pointer, ref server, ref port); SearchForUpdatedMessage(sender, pointer, server, port, folder.StoreID); //try to delete it directly (may not work) try { mail.UnRead = false; mail.Move(store.GetDefaultFolder(OlDefaultFolders.olFolderDeletedItems)); mail.Save(); } catch { //couldn't delete - probably locked //mark as 'read' mail.UnRead = false; mail.Save(); } return true; }
private void AfterTraining_Spam(MailItem mi) { if (this.config.AfterTraining_Spam_DoDelete) { // delete mail mi.Delete(); } else { // mark as read if (this.config.AfterTraining_Spam_MarkAsRead) { mi.UnRead = false; mi.Save(); } // prefix if (this.config.AfterTraining_Spam_DoPrefix) { mi.Subject = this.config.AfterTraining_Spam_PrefixWith + " " + mi.Subject; mi.Save(); } // move if (this.config.AfterTraining_Spam_DoMove) { if (this.config.AfterTraining_Spam_MoveTo != "") { mi.Move(this.mailparser.getFolderByName(this.config.AfterTraining_Spam_MoveTo)); } } else { // do nothing } } }