I need to filter emails by the received date using a value from Excel config.
The date value from config is in the format string = “01052026 12:00:00” (ddMMyyyy HH:mm:ss).
Currently, I am using the “For Each Email” activity and want to apply this filter in the Additional Filters section.
if you are filtering outlook mail messages mail header property will have the received date:
Dim ReceivedDate As DateTime = OMailMessage.Headers(“Date”)
as for your date string - you need to parse it to proper date var
Dim DateInput As String = “01052026 12:00:00” 'ddMMyyyy HH:mm:ss format
Dim format As String = “ddMMyyyy HH:mm:ss” 'which format should it read as.
Try
Dim ResultDate As DateTime = DateTime.ParseExact(DateInput, format, CultureInfo.InvariantCulture, DateTimeStyles.None)
Catch ex As Exception
Console.WriteLine("error: " & ex.Message)
End Try
First get date from your config file and convert that in datetime format from string.
Then use that filtered datetime in for each email in addition filter.
Expression to convert the config date in datetime format
From above screenshots
First assign activity, strDate is getting from config file.
If you dont want to use this assign activity, in second assign you can directly wirte expression as like below,
If you dont want use 365 activities,
Use the activity
Get Outlook Desktop Mail Messages this will ge the email and here in property section there additional filter property under that you can use below expression,
And create a output variable for this activity(lstMailmessages),
then use For each activity, pass above created variable lstMailmessages in for each activity.