How to search keywords to find documents filename(PDF,Excel 100+)then send the documents by outlook at specified time

I am a beginner with UiPath.
email password.xlsx (8.7 KB)

I am now trying to do an automation project to send emails attaching the required files (encrypted PDF & excel) of the same person and then send out the email at a designated time to that person. Can anyone help or make a sample file to teach me step by step? For those items who cannot be done by using UiPath, feel free to let me know.

  1. I want to select multiple files (encrypted PDF & Excel) in the computer about the same person to be attached with the email (using outlook) and then send this email to that person. One email for one person. (see attached excel for reference: the employee name, password for the pdf and email address are on the attached excel password document)

Here is the sample content of the email:

Dear (name of the designated person ← if this is not possible, it can be changed to “colleague”),

Please find the attached documents for your reference.

Here is the password of the file:
Password (of the pdf): (automatically fill in the password based upon the excel)

Thanks.

XX Department
XXX Limited

Note: This message needs no reply.

Attachment: (Related PDF, Excel files)

  1. Set a specific time for sending outlook, for example, sending outlook at 11 a.m. on the 7th of every month.
    (if the 7th is a public holiday or a Saturday or Sunday, the time will automatically be set to the next working day (Mon – Fri) to send Outlook. Is it possible to do this?)

Appreciate for your help.
Thanks:)

Hey @helen3
You can try implement it this way:


Next, Use Send Outlook Mail Message

  • Set the “To” property to emailAddress.

  • Set the “Subject” .

  • Set the “Body” property to emailBody.

  • For attachments, if the paths are stored in variables (e.g., pdfFilePath and excelFilePath), use the “AttachmentsCollection” property to add them.

  • Use UiPath Orchestrator to schedule the automation. Set it to trigger at 11 a.m. on the 7th of every month.
    0 0 11 7 * ? *
    image

Thanks @pikorpa.

For attachments, can I attach the files using employee name (e.g. Karen) to search inside a folder for the required pdf and excel instead of using variables (e.g., pdfFilePath and excelFilePath)?

Hey @helen3
Sure. you can find attachments like this:
Directory.GetFiles(folderPath, employeeName + "*.pdf")
or for xlsx files
Directory.GetFiles(folderPath, employeeName + “*.xlsx”)

then you can use if activity:
If pdfFiles.Count() > 0 , then attach pdfFiles.First()

Hi @pikorpa,
From orchestrator, if the 7th is a public holiday or a Saturday or Sunday, the time will automatically be set to the next working day (Mon – Fri) to send Outlook.
Is it need to add character W inside of 0 0 11 7 * ? * ?
It can‘t be 0 0 11 7W * MON-FRI *
How can I change into?

@helen3
Regarding the cron expression: 0 0 11 7W * ? * - At 11:00 AM, on the weekday nearest to the 7th day of the month, this expression schedules the task to run. However, it does not account for public holidays. Since it does not support skipping public holidays, consider implementing logic within your UiPath workflow to check if the current day is a public holiday. However, this solution may require delaying your process, which might not be ideal.

In my opinion, the best approach would be to schedule the process to run every day except weekends. In the code, you can check whether the process should continue. You can achieve this using the following VB.NET code, which returns a Boolean value indicating whether the process can continue or not.

Dim targetDay As DateTime = New DateTime(DateTime.Now.Year, DateTime.Now.Month, 7)
Dim canContinue As Boolean = True
If targetDay.DayOfWeek = DayOfWeek.Saturday OrElse targetDay.DayOfWeek = DayOfWeek.Sunday Then
    targetDay = targetDay.AddDays(1)
End If
If targetDay.DayOfWeek = DayOfWeek.Sunday Then
    targetDay = targetDay.AddDays(1)
End If
If publicHolidays.Contains(targetDay) Then
    Do
        targetDay = targetDay.AddDays(1)
    Loop While targetDay.DayOfWeek = DayOfWeek.Saturday OrElse targetDay.DayOfWeek = DayOfWeek.Sunday Or publicHolidays.Contains(targetDay)
End If
canContinue = DateTime.Now.Date = targetDay.Date
processCanContinue = canContinue

Please take a look at this workflow. I hope it helps. :wink:
BlankProcess126.zip (9.4 KB)

Hi @pikorpa,

May i know the public holiday is using the Calendar in US or ……. Which country? Can it use the public holiday in Hong Kong ?

Thanks.