Attaching email to record based on subject line?

Attaching email to record based on subject line?

Is it possible to create a workflow custom function that would be able to identify emails via IMAP where the subject line contains specific words and match them to a record where those words match a specific field?

For example, if we have a case named Smith/Jones, is there any way to have a workflow function grab any emails that have the words Smith/Jones in the subject line and automatically attach them to a record where the case name is Smith/Jones?