0 votes


I want to add a button on Project which have to send mail to all contacts linked to the project.
I know how to create the button but the mail will use a Mail Template to generate the mail body, and each mail have to contain an attachment, this attachment come from a Document Template.

I think my script have to :

  1. Get the ntCont detail dataset of the Project and loop on it
  2. For each Contact
    2.1 merge the Word/PDF Template
    2.2 merge the Mail Template
    2.3 Link the both
    2.4 Send the mail with "SendExternalMail" ?

I have some questions :
Can I send all the mail with only one call ? (after the loop ?)

Questions for the Word/PDF Template :
The function will be call on the Project consult view.
My function will get the Contacts detail dataset and launch the Template for each of them. In this template I use these macro :

[$=COMP.NAME] --> need the Main Company NAME of the Contact
[$=CONT.NAME] --> need the current Contact name
[$=OPPO.NAME] --> need the Main Opportunity name of the project

How can I get all of these data ? If I call MergeTemplate with the Contact Edit Context, I think CONT.NAME and COMP.NAME will be good, but I don't think the OPPO.NAME will be the good one : Efficy will take the main oppo of the contact, and not of the project.
I think I can get this name before and pass it as argument it to the template (param of MergeTemplate), how to use it in the template ?

SendExternalMail don't specify how to join a file, have I just to link the mail to the ntFile ?

asked in WorkFlow / Serverscript by (245 points)
edited by

1 Answer

+1 vote


It's best to open a task context and insert the company, contact and opportunity as details. Then execute the merge context. You can decide to commit the task and mark it as done (recommended) or to closecontext without commit.

You can't send e-mails with attachments using the sendExternalMail API, Efficy can only do this client side using your own Outlook.

Since Efficy 11.0, you could generate a token and mail the link to download the attachment.

answered by (6.9k points)
Thanks for your answer, Open a task is a really good idea, I will modify my script

But I have a problem with the "client-side" part :

The project may have multiple contacts (maybe 1, 2, 3 or 12, etc.). My script have to send a mail to each of them ! I mean that each email will have :
- a specific body (generated with the mail template)
- a specific attachement (generated with the Word template)

So if I use Outlook to send the mail, I think I have to open one window for each of these email, and it's really not a good idea I think.

Maybe Publication can help me to achieve that ? If yes :
Can publications do it --> generate the specific mail with the specific Word in each mail and automatically send it with the mail dispatcher ?
You will have to go for a request to send an external mail per e-mail and so have all new mail objects opened in outlook. The campaign module will not help. This is typically for sending server side, but there we don't support attachments
1,173 questions
1,433 answers
325 users