I wonder how that could be scripted since persistent storage via the DB isn't a thing here.
It couldn't be picked up normally by a conversation dialogue, cause you may be holding multiple letters so it might have to do something like convert the title and description of a letter into a string that's saved on the NPC themselves after using the unique power of the note on the NPC which initiates a dialogue where you type someone's name on who should receive it.
But NPCs will reset after 15min if no one visits the inn, so you can't store integers or the item itself on the NPC either...
Maybe it gets saved to an invisible object that doesnt despawn? And the NPC just does the dialogue for handing out letters by recreating the item based on the strings saved to that object and tied to the character name listed originally.
Think it seems easier to just leave a wax sealed envelope by the innkeeper, if the player gets it they get it, and trust that other players will ask a DM to possess the NPC if they want to pretend to be the intended recipient before taking it.