When considering a ditransitive verb, be it English or German, it helps to keep the model verb "give" (for English) or "geben" (for German) in mind. The direct/accusative object is the object being given, while the indirect/dative object is the object being given to, where the direct object ends up. Observe:
Ich gebe dir eine Nachtricht.
I'm giving you a lettermessage.
In English, and German apparently, verbs of creation (make, bake, build and, yes, write) can be ditransitive, implying that the direct/accusative object (the thing created) was made for and thus given to the indirect/dative object.
Side note: the fact that English still puts indirect objects before direct objects, despite completely collapsing the distinction between dative and accusative even in the pronouns, is probably the source of your confusion. Just remember: In ditransitive verbs, the indirect object comes first, and that takes the dative in German.