Capture UNID from outgoing email in custom application

I have a custom application that has to send emails using each person’s mailfile. This is going to happen from an action button on a form in the application if they select email from a dropdown.

What I need to do is find a way to capture a link to the email after it is created and place a doclink back to it on the form in the new application.

I am using @Command([MailComposeMemo]) to open the memo form, but do not know how to grab the UNID at that point to create the doclink in the originating application. I really do not want to modify the mailfile for obvious reasons but I cannot come up with an alternative.

Can anyone think of a better way to do this?

Subject: The mail memo is assigned an UnID when it reaches the recipient mail file

I don’t think you can know it when you send. The whole idea of linking to someone’s mail box sounds really strange to me (if I understood this correctly).

Subject: The UNID for the local copy is available POST save (such as in the PostSave event).

Of course, the UNID will be entirely different in the recipient’s mailfile, correct.

Thomas - IBM

Subject: Capture UNID from outgoing email in custom application

$messageid perhaps, you’d also have to capture either the users name or their mail file (depends if they might change) - it might require a view (sorted by $messageid) added to the mail template but that’s only a minor change.

you’d also have to cater for the user deleting the message once it’s in their mail file, your link won’t work anymore.

you may also have to shift to lotusscript so you have access to the document after it’s been mailed

Subject: Depends

The UNID isn’t available until after the document has been saved/mailed.You could grab the NoteID instead (which IS available even if the doc is new) and use that to find the (saved) document (in Lotusscript, use NotesDatabase.getDocumentByID), and then grab the UNID. Of course that only works if the sent document is actually saved in the mail file.

Thomas - IBM

Subject: RE: Depends

I had the same thought but I am not sure how to grab the ID. As soon as the user clicks on the action button, the app loses focus and control. How would I capture the NoteID (or UNID) and pass it back to the app upon Save/Close of the memo?

There has to be a way to do it, however it is escaping me at the moment.

A thought was to do a dblookup on the $All view in the mail file and grab the last document, but that is not foolproof either.

Any other ideas?

Subject: Good point

I didn’t take into consideration that you’re invoking the standard email form in the mailfile.Usually the way you do this is to have code in the PostOpen, PostSave or PostSend event to capture stuff like this, but you can’t ‘subclass’ events from forms coming from another db. Maybe you need to re-think your design approach in order to get what you want. For example, you could add a mail-enabled form to your own app (which you have total control over), let the user send the email from that form, and copy that email document into the users mailfile, if required, etc.

Thomas - IBM