AnsweredAssumed Answered

Grab 'from' email address from 'emails_text' table - Raw SQL or Beans

Question asked by dnolan dnolan on Oct 12, 2015
I have an inbound email that creates a case, assigns it to a rep and then sends a threaded email to the rep.

I need to get the inbound emails 'from' address, and I know how to do it in mySQL, but not with beans so...

How I achieve something like this by using beans, or if not possible, by raw sql in my logic hook?

$caseID = $bean->id;

$emailID = SELECT email_id FROM emails_beans where bean_id = '$caseID';

$fromAddress = SELECT from_addr FROM emails_text WHERE email_id = '$emailId';

So first I'm grabbing the email_id by using the 'emails_beans' table, where I can find it by using the $caseID for the bean_id.
Lastly I use this emailID to look up the from address from the emails_text table where it is stored.

Guidance appreciated, thanks