Verify PDF content and send email with PDF attachement accordingly

Hi all,

Here’s what I am trying to do:

  • read PDFcontent of all PDF files in folder (without opening those PDF files);
  • verify if PDFcontent of the file contains a certain string of characters;
  • If yes, then send email with THAT pdf attached.

What would be the process to configure that? Please help.
Thank you!

Hi @jphil2,

Use a for each loop to loop through each pdf file in the folder.
Inside the loop, for each pdf

  1. Read the file using read pdf activity
  2. In the obtained output string, Check the condition - if string you are looking for exists
  3. If it exists use send outlook mail message and in the attachments property pass the filename along with its path as an in argument to send the email.

Thanks for the reply @Vinutha!
Sounds simple enough. But, is this the vbscript that should be assigned to the variable in the assign activity that precedes the For each loop ? Directory.GetFiles(“whateverfolderpath”, “*.pdf”)

You dont need an assign statement, you can directly pass it to for each

1 Like

Great. I think I am almost there. How do I attach the specific PDF file that contains my string to my sent email?

image

@jphil2 you can pass the path of file in the value field as path.GetFullpath(file)

In this For loop, file represents each filepath that is in the list created by GetFiles(). Therefore, you can use that variable as your Value for the In argument. So, it will use the filepath that you are looping through.
image

Note: it will already be the full filepath, so there’s no need for GetFullpath()

Regards.

1 Like

That is what I tought, but I still have this error message:

:thinking:

or with path.GetFullpath(file)

Convert it to string as file.toString()

Yeah, it’s an Object because the TypeArgument property on your For Each is set to Object, therefore file is an Object. But, like @Vinutha said you can add .ToString on the end to make the Object into a String. You can also just simply change the TypeArgument of the For Each to a String type.

Thank you both. I believe it works, I have no more errors.:+1: Now, I must verify why the read pdf activity doesn’t seem to be able to capture my string of characters in the files…, which is there in some files… Cheers.

Just to confirm, it worked! Cheers.