In both sentences, the word you are talking about is the direct object. If there is no possibility of doubt, we may simply call it the 'object'.
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.
hanuman_2000 I wrote a letter.object = "a letter", Can we call it as direct object?We just call letter' the object of the verb 'wrote'.