Read only emails w specific keyword in the subject

email
studio

#1

Hello Everybody,

I created a code that should read through 4 different email inboxes and move all emails containing a specific keyword and after that save all attachments to the folder relating to the keyword.

To do so I iterate first through the rows of a datatable and store the keyword, the inbox address, the folder path in variables. Then I use these variables to read through the emails and to identify the subject.

From everything I find here, my code makes perfect sense. However, if I run the code it saves only a few emails and in random folders (can’t see the logic behind).

I would be very happy if somebody could look at my code and tell me where it might be weak.

Thank you very much!

Cheers,
Tina

EmailContains.xaml (33.0 KB)


#2

Your get email activity is set to Top 100 - is that possibly limiting the results?


#3

Hi Richard,

Thanks for your reply. That might be something to consider.

However it won’t solve my problem since I have in my inbox around 10 emails for testing purposes and it doesn’t even work for them.


#4

Hi,

it seems that you loop through your mailmessagesJE but still take the the very first MailMessage item when saving attachments and moving the message:
image

If you want to use the actual mail that is true with mail.Subject.Contains(strCompanyCode) then just add ‘mail’ in the properties.

Br,
Topi


#5

Thank you so much that solved my problem