Resolved questions「いただきます」の使い方

I know that this word is always used before starting to eat something. However, I've also heard in many J-dramas that this word is used in a formal way while receiving something from someone (or something like that). Can you please tell me in what kind of other situations this word can be used other than saying this before eating something?ありがとうございます。