#3052 - How to Mail Merge and Attach to Email through Coding
I have a custom module called "Transactions". These are related to Opportunities (Sales in our CRM).
When Payroll goes to pay our Agents on an Opportunity we have a custom feature which automatically creates Transactions for them.
What I want to do for them is help automate the Statement process.
Currently they have to manually create Statements in Excel from the Transactions and individually send them out the Agents.
I want to create a Mail Merge from the Transactions module and then when they click 'Pay' from the Opportunities module, have it mail merge and attach to an email and send that out automatically for each person.
These 2 websites detail how to send out an email from Sugar through the code: https://developer.sugarcrm.com/2011/08/15/howto-send-and-archive-an-email-in-sugar-via-php/comment-page-1/#comment-50205 https://johndopenotes.wordpress.com/2013/03/26/sugarcrm-send-email-with-attachment-using-sugarphpmailer-class/
I'm just trying to figure out how to create the attachment from Mail Merge Reports and then attach it to an email and send it out, but ensure the email gets put in the History Subpanel.
Any help would be appreciated. Thanks!