The focus is on the Memo when you create the doclink. I can’t see, though, why you aren’t just using this @MailSend to create and send the doclink message.
There are two ways to do what you are wanting to do. Both ways require you to make sure your document is saved first. Additionally, if you are using it in a view, your document must be in at least Read or Edit mode.
The First method is to use the following at the end of your MailComposeMemo code:
@Command([EditInsertFileAttachment] ; “\\your server here\path\path\path\path\document name”
A better method requires just a few more steps added to what you have tried.
In your MailComposeMemo code at the top, declare your DocLink as a temporary variable, something like this:
tmp := @Command([EditMakeDocLink])
(That first copies the doc into the users clipboard BEFORE your mail code is run.)
Then at the end of your MailComposeMemo code enter the following: