I have that report coming in everyday with real time date for each and everyday.
When I am running my bot it filters the attached file for a current date, it cannot filter for maybe a date from yesterday.
Here are my assign dates:
To filter email attachments with names containing the current date and the previous date in UiPath, you can use the “Get Outlook Mail Messages” activity to retrieve emails with attachments and then use string manipulation and DateTime functions to filter the attachments based on their names.
Here’s a step-by-step guide on how to achieve this:
Use “Get Outlook Mail Messages” Activity:
Drag and drop the “Get Outlook Mail Messages” activity into your UiPath workflow. Set the necessary properties like the account, mailbox, filters, and other options to retrieve the emails with attachments.
Loop Through Email Messages:
Use a “For Each” loop to iterate through each email message obtained from the “Get Outlook Mail Messages” activity.
Extract Attachment Names:
Within the loop, use the “Save Attachments” activity to save the attachments to a specified folder on your system. This will also provide you with the attachment names.
Filter Attachments Based on Dates:
Implement string manipulation and DateTime functions to filter the attachments based on their names containing the current date and the previous date. You can use the DateTime.Now function to get the current date and then use DateTime.AddDays(-1) to get the previous date.
For example, to check if the attachment name contains the current date (in the format “yyyyMMdd”) or the previous date, you can use something like this:
currentDate = DateTime.Now.ToString("yyyyMMdd")
previousDate = DateTime.Now.AddDays(-1).ToString("yyyyMMdd")
For Each attachmentName In attachmentNames
If attachmentName.Contains(currentDate) Or attachmentName.Contains(previousDate) Then
' Process the attachment or save it to another folder
End If
Next
Note: attachmentNames should be an array or list containing the names of the attachments retrieved from the “Save Attachments” activity.
Perform Actions on Filtered Attachments:
Inside the loop, perform the desired actions on the filtered attachments, such as saving them to a specific folder, processing their content, or any other required operations.