both are correct, but depends on the context when you use it, the first sentence is a statement, the second one is used to answer a question, you can compare it with my translation:
1) i sent him a message (equals 我给他发了短信)
2) A: have you sent the message to him?
B: yes i have. (equals 我给他发短信)
time adverbial could be added before or after subject, but rarely appears at the end of the sentence. you can see the difference from my example:
1)I sent him a message yesterday, but haven't got his feedback (both 昨天我给他发了短息 and 我昨天给他发了短息 are right)
2) A: when did you send the message to him?
B: I sent it yesterday. (equals 我昨天给他发的短信, to emphasize the time)