The conventional rule for indirect objects is that the preposition can be omitted if the indirect object goes between the verb and the direct object:
I gave the message to him - verb-direct-to-indirect
I gave him the message - verb-indirect-direct
What's happening in the first sentence is that there is a relative clause with the relative pronoun that. In spoken English, the relative pronoun can be omitted: here is your first sentence as it would be written in formal English, with the relative pronoun included:
Open the file that I sent (to) you.
In the second sentence, what is acting like a pronoun that represents the direct object.
In both cases, then, the direct object is a pronoun at the front of the clause, so the indirect object cannot go between verb and direct object. When parsing the sentence, we understand that the direct object has been fronted, so it's OK to omit the preposition even though we just have verb + indirect object. One of the answers to this question confirms that the omission is permissible.
Note that it is also OK to omit the preposition for, for example:
He ate the sandwich that I made for him
He ate the sandwich that I made him
Note that, if the relative pronoun is used to represent the indirect object, the preposition cannot be omitted. In some cases, you end up with a dangling preposition:
the girl that I lent my jacket to
the person that I poured a drink for
I don't know the man to whom you sold the house
Note that, in very informal spoken English, you may hear the preposition omitted from sentences like the first one. You may also hear final sentence produced incorrectly, but in this case the to is never omitted:
I don't know the man who you sold the house to