email parsing automation

Email Parser

Extract data from emails and automate your workflow

The forum is now read only. Please, go to the the main Email Parser website if you need help.
Need help configuring the program? Have any questions regarding its use?
Hi all, thank you to accept my registration!
I'm very bad with the code so I'm sorry if I have a stupid question :)
Is it possible to filter emails in a time window? Exemple I would like that all the e-mails received by a sender from 22h30 to 8h30 are deleted and form 8h31 to 22h299 are forwarded to another mail account.
Yes, definitely possible.
Check out: ... filters-18
You will need to edit that C# script to read the sent date/time stamp, and only consider the time portion, i.e. ignore the date portion, then assign the boolean to either true or false.

Here is a prototype of that:
Code: Select allusing System; using System.Net.Mail; using AutomatedEmailParser.Logic.ScriptingInterface; public class MyFilter : ScriptBasedEmailFilter { public override bool FilterEmail(MailMessage msg) { // // Example: (NOTE: Prototype, to be tested) // Check at what time of day the email was sent bool condition1; TimeSpan startNight = new TimeSpan(22, 30, 0); //22:30 (10:30 PM) TimeSpan endNight = new TimeSpan(8, 30, 0); //8:30 (8:30 AM) DateTime receivedDate; TimeSpan receivedTimeOfDay; try // Read the Sent date/time fron the message header { receivedDate = Convert.ToDateTime(msg.Headers["Date"]); receivedTimeOfDay = DateTime.Now.TimeOfDay; } catch // Use the current time (should be close enough if the service is running, executing every 1 or 5 mins) { receivedDate = DateTime.Now; receivedTimeOfDay = DateTime.Now.TimeOfDay; } if ((receivedTimeOfDay > startNight) && (receivedTimeOfDay < endNight)) { condition1 = true; // Email sent at night } else { condition1 = false; // Email during the day } // The email is not blocked if sent at Night return (condition1); } }
UPDATE: Turns out there was already a similar question asked and answered, so you have another answer to this question here: ... -t125.html