Poco Composing FAQ - Sending a second message when using a template

Q: I have a template and want that whenever I use this template to reply to a message another message (also saved as template) should also be sent to the same user.

Is there any way of doing this thing or I will have to continue doing this thing manually!

 
A:
You could do this via a script. How you implement it depends on your requirements. If you only envision doing this for this one template and the subject line is unique (there is no chance you will use it anywhere else) then I'd recommend setting up a filter to watch for an outgoing message with the subject line and then triggering the script when it is detected.

If you want a more generic solution, say to allow this facility to run from several templates, then I'd suggest either:

  1. Putting a special custom header in the template (I haven't tested this, I seem to recall at one time Poco may have not honoured these but don't know if I'm correct in that nor if it has been fixed).
  2. Adding a custom common variable tag to the template. The script would detect this and then send the extra message.
As for the script, it would be relatively simple. In the first case (unique subject) it would simply use the "CreateMessage" command to instance a new message, extract the "To:" information from the outgoing message, read the template file (using the OpenBody command) and send the message.

If you decide on the more generic solution then I would recommend one additional step, deleting the header or custom common variable tag from the original outgoing message before you send it (I haven't tested this, it may result in duplicate messages so test it out). If this works it will prevent you accidentally sending the second template a second time if you reply to a reply to your initial message.

Note: Using templates in this fashion will not cause the common variable tags to be replaced in the second message. If you use them for the second template then you will have to code the replacement logic yourself.