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 :
- Get the ntCont detail dataset of the Project and loop on it
- 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 ?