Need help

Hi there

I need help to set up a script which could tell me which electricity period is applied.
I have three different. Blue White and Red. The red one is the most expensive.
I receive a mail at 5 PM o’clock which tells me the next day will be white or red. No mail if it is blue.
It would be nice if I can have a solution to read a mail subject. Look up which color is contained in this subject and update a database. When no mail is coming who to update to blue?

Any help will be welcome.

Thanks in advance

Ossy