Hello All,
I am learning to use UiPath with the academy courses to retrieve the content from email and get the cell data from email attachment. Because the different software version. I cannot follow the tutorial video to get the cell value from excel sheet.
I want to retrieve the cell value from “E8” and below is the flow I have created.
Anyone can help to figure the problem is?
Kindly share the error you are getting. You can mouse hover on the read cell value to get the error details
Also i am sharing the correct format for read cell. If you are new to UiPath - you could use the indicate in excel option and select the cell which you want to read. Click on tick mark in the above
Correct Format is - Within Use Excel File - ReferenceExcelName.Sheet(“SheetName”).Cell(“CellAddress”)
@sharazkm32 and @ashokkarale
Thanks for providing the correct format to retrieve the cell value. And the indicate function is good for me to easily select the cell I need.
But I am facing with another problem. I am not sure the file path I set is able to access each excel file or not? It seems not catch the cell value correctly.
Filter the outlook mails and select the title contains “[Subject]=‘Course Invoice’”
Save the email attachments (Excel file) to “Invoices” folder under current package folder
Go through each excel file to retrieve the E8 cell value (Client Code) and paste the client code to a webpage and get the discount code than copy paste the code to each excel file.
Hey @yanlinc Just try this and let me know
Step 1: Filter Outlook Emails Based on Subject
Open UiPath Studio and create a new sequence.
Add the “Get Outlook Mail Messages” activity to your sequence.
Configure it to connect to your Outlook account.
Set the “Filter” property to:
“[Subject] = ‘Your Subject Here’”
Replace 'Your Subject Here' with the actual subject you want to filter by.
Set the “Output” property to a variable, e.g., mailMessages.
Step 2: Save Attachments to a Folder
1 Add a “For Each” activity to loop through the filtered mail messages.
Set the typeargument to System.Net.Mail.MailMessage.
Set the “Values” property to mailMessages.
2. Inside the “For Each” activity, add an “If” activity to check if the email has attachments:
mail.Attachments.Any()
Inside the “Then” branch of the “If” activity**, add a “For Each” activity to loop through the attachments.
Set the type argument to System.Net.Mail.Attachment.
Set the “Values” property to mail.Attachments.
Inside the “For Each” activity, add a “Save Attachment” activity to save the attachment to the desired folder.
Set the “MailMessage” property to mail.
Set the “Attachment” property to attachment.
Set the “FilePath” property to:
"YourPackageFolderPath\" + attachment.Name
Replace "YourPackageFolderPath\" with the actual path to your package folder.
Step 3: Retrieve Value from Cell E8 in Each Excel File
Add a “For Each” activity** to loop through the saved Excel files in your package folder.
Set the type argument to String.
Set the “Values” property to:
Replace "YourPackageFolderPath" with the actual path to your package folder.
2. Inside the “For Each” activity**, add an “Excel Application Scope” activity to open each Excel file.
Set the “WorkbookPath” property to file.
3. Inside the “Excel Application Scope” activity, add a “Read Cell” activity to read the value from cell E8.
Set the “SheetName” property to the appropriate sheet name (e.g., "Sheet1").
Set the “Cell” property to "E8".
Set the “Output” property to a variable, e.g., cellValue.
[Sample Workflow Snippet]
Get Outlook Mail Messages
Filter: "[Subject] = 'Your Subject Here'"
Output: mailMessages
For Each mail In mailMessages
TypeArgument: System.Net.Mail.MailMessage
Body:
If mail.Attachments.Any()
Then
For Each attachment In mail.Attachments
TypeArgument: System.Net.Mail.Attachment
Body:
Save Attachment
MailMessage: mail
Attachment: attachment
FilePath: "YourPackageFolderPath\" + attachment.Name
For Each file In Directory.GetFiles("YourPackageFolderPath", "*.xlsx")
TypeArgument: String
Body:
Excel Application Scope
WorkbookPath: file
Body:
Read Cell
SheetName: "Sheet1" // Replace with your actual sheet name
Cell: "E8"
Output: cellValue // Variable to store the value
This error occurs when you try to read the empty cell into a non object variable.
Try this:
Declare this ClientCode variable as Object Datatype
Declare another variable in desired datatype like doubleClientCode
Use If Activity to check if ClientCode is not nothing like this: ClientCode IsNot Nothing
If nothing you can assign some default value like 0 and if got some non null value convert and assign to the doubleClientCode liek doubleClientCode = CDbl(ClientCode)
@sharazkm32 and @ashokkarale,
Thanks for you all helping with this.
After unchecking the options and change the Client Code data type to object, I successfully retrieved the data from excel file separately.
Any recommend way for a beginner to learn and try to pursuit a job related to automation developer? I am working on this.
out of context question, but i have one doubt, if i am filling details in one excel which have two sheets , how can i check this condition like if sheet1 already exists then apppend row if it doesnot exists then write range , and same for sheet 2, so basically to check if the sheet exists