0 votes

Hi all,
I would like to do something the the newly created email in efficy 10 when I use sendExternalMail() ( - and sendMailToUsers() if also possible).
How can I determine K_MAIL? The online docu offers nothing.

Thank you


asked in WorkFlow / Serverscript by (177 points)
BTW, nice to see you are still involved in Efficy projects :-)

1 Answer

0 votes

Hello Tim.

I recently made a suggestion to improve this in standard since the function sendExternalMail doesn't return anything. Starting from Efficy 11.1, it will return K_MAIL.

A work around is to query the MAILS table.

For instance when send the mail from the context of a document

Efficy.sendExternalMail(sendFrom, sendTo, "", subject, body, ntDocu, k_Document, 'U');

You can join the two together and fetch the K_MAIL:

select m.K_MAIL from <#TABLE NAME=MAILS> m
inner join <#TABLE NAME=MAIL_DOCU> md on m.K_MAIL = md.K_MAIL 
where OPENED='1' and md.K_DOCUMENT=:p1


answered by (7.4k points)
Hi Kristof, hope you are doing well!
I though the same way, but in my case this is not working - I have no unique entity linked to it! I can solve it in another - not so easy way ...

Thank you for answering!

Well yeah, you can query MAILS directly after executing the sendExternalMail and take the last record, although this is not 100% save. Or you store some unique number in the mail body (or subject) and use it to query more precisely.
1,248 questions
1,518 answers
328 users