Email Challenge: This is similar, but unlike other Topics

pdf
ocr
email
studio

#1

Hi. I am trying to make a simple routine:

  1. Open outlook mails (from inbox) that have “Invoice” as subject AND have an attachment
  2. Save pdf attachments AS PDF
  3. Open 1st pdf and read data into excel/csv
  4. Close pdf, read next pdf.

I cannot find a simple answer to this. My code is as per the image below. One problem is that UiPath saves the pdf attachments as ZIP files. Also I dont know how to open the saved pdf files to extract the data.

Please help - thank you!


#2

Hi,

Attachments into zipfiles strange :thinking: However you can follow up below steps:

Couple of ways to convert to excel as below


#3

Hi ddpadil,

I have managed to save as pdf - thanks. Status is I have my files on drive. I can read only one despite my loop. What am I missing? Also, my filter does not seem to work (I set a filter to save only “Invoice” message attachments; these messages have “invoice” in the subject). Kindly advise on my loop and my filter.

Thanks!! Nic

CheckForInvoiceMailV2.xaml (12.0 KB)



#4

Hi,
Fair enough :slight_smile:
After saving the pdf in local drive follow this .
assign strArryVar=Directory.GetFiles(“your pdf file folder”)
Foreach item in strArryVar
Use Start process activity and pass item
post to that followed by data scraping and appending to excel.

Here we go.
CheckForInvoiceMailV2.xaml (15.9 KB)


#5

Hi ddpadil,

Thank you so much for the code - you ROCK!!. It seems to be working BUT for some reason it cycles through the pdfs twice and my output includes duplicate records in excel. I have not adjusted your code much, but I will attach anyway.

Cheers mate!

Nic
CheckForInvoiceMail(Forum).xaml (16.8 KB)


#6

Strange .:thinking:
Its working fine for me.
Just to make sure how many files its reading you could just pass this code in message box after file assignment.
file.Count.ToString

filecount


#7

Hi Ddpadil,

All working perfectly now!! I dont know exactly what happened but I applied a mail filter, and the counter to check. Now all good.

Thank you so much!

Nic


#8

DDPadil and NIC,

I have a similar issue, I would want to open all unread emails in a folder with multi attachments but save only PDF files to Local Folder. Once Saved I would want to open the first PDF file, do a Read PDF message box and close the file open second file saved from other mail and loop till all files are read and then move them to processed folder.