{"id":321,"date":"2020-05-21T17:58:55","date_gmt":"2020-05-21T17:58:55","guid":{"rendered":"https:\/\/www.techcrm.in\/blogs\/?p=321"},"modified":"2020-09-08T14:51:14","modified_gmt":"2020-09-08T09:21:14","slug":"email-template-with-attachment-sugarcrm-suitecrm","status":"publish","type":"post","link":"https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/","title":{"rendered":"Email Template With Attachment \u2013 SugarCRM \/ SuiteCRM"},"content":{"rendered":"\n<p>If user want email with attachment this can be done very easily in SugarCRM \/ SuiteCRM. Steps are as below,<\/p>\n\n\n\n<p><strong>Step 1 :<\/strong> Get the Email Template detail using following code,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>require_once(\u2018modules\/EmailTemplates\/EmailTemplate.php\u2019);\n$emailTemp = new EmailTemplate();\n$emailTemp->disable_row_level_security = true;\n$emailTemp->retrieve($emailTemplateId);\nprint_r($emailTemp);<\/code><\/pre>\n\n\n\n<p><strong>Step 2 :<\/strong> Get the Attachments of Email Template using following code,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>require_once(\u2018modules\/EmailTemplates\/EmailTemplate.php\u2019);\nrequire_once(\u2018modules\/Notes\/Note.php\u2019);\n$note = new Note();\n$where = \u201cnotes.parent_id =\u2019$emailTemplateId'\u201d;\n$attach_list = $note->get_full_list(\u201c\u201d, $where, true);\nprint_r($attach_list);<\/code><\/pre>\n\n\n\n<p><strong>Step 3 :<\/strong> Sending Email Code using following code,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$html=\u201dAddtional text\u201d;\n\nrequire_once(\u2018include\/SugarPHPMailer.php\u2019);\n$mail = new SugarPHPMailer();\n$mail->ClearAllRecipients();\n$mail->ClearReplyTos();\n\n$mail->From = $FromEmailAddress;\n$mail->FromName = $FromEmailAddress;\n$mail->Subject = from_html($emailTemp->subject);\n$mail->AddAddress(\u201csendingmailid\u201d, \u201cname\u201d);\n$mail->AddAddress(\u201csendingmailid2\u201d, \u201cname2\u201d);\n\n$mail->Body_html = from_html($emailTemp->body_html);\n$mail->Body = wordwrap($emailTemp->body_html, 900);\n$mail->Body.=$html;\n\/\/ Add attachemts to the Email Start\n$attachments = array();\n$attachments = array_merge($attachments, $attach_list);\nforeach ($attachments as $attached) {\n$filename = $attached->filename;\n$file_location = \u2018upload\/\u2019 . $attached->id;\n$mime_type = $attached->file_mime_type;\n$mail->AddAttachment($file_location, $filename, \u2018base64\u2019, $mime_type); \/\/Attach each file to message\n}\n\/\/ Add attachemts to the Email End\n$mail->IsHTML(true); \/\/Omit or comment out this line if plain text\n$mail->prepForOutbound();\n$mail->setMailerForSystem();\n\n\/\/Send the message, log if error occurs\nif (!$mail->Send()) {\n$GLOBALS&#91;\u2018log\u2019]->fatal(\u2018ERROR: Message Send Failed\u2019);\n}<\/code><\/pre>\n\n\n\n<p>Hope you find this blog post helpful.<\/p>\n\n\n\n<p>Feel free to add comments and queries, that helps us to improve the quality of posts.<\/p>\n\n\n\n<p>You can contact us at&nbsp;<a rel=\"noreferrer noopener\" href=\"mailto:contact@urdhva-tech.com\" target=\"_blank\">info@techcrm.in<\/a><\/p>\n\n\n\n<p>Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If user want email with attachment this can be done very easily in SugarCRM \/ SuiteCRM. Steps are as below, Step 1 : Get the Email Template detail using following code, Step 2 : Get the Attachments of Email Template using following code, Step 3 : Sending Email Code using following code, Hope you find [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,9],"tags":[84,83,12,13],"class_list":["post-321","post","type-post","status-publish","format-standard","hentry","category-sugarcrm","category-suitecrm","tag-attachments","tag-email","tag-sugarcrm","tag-suitecrm"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Email Template With Attachment \u2013 SugarCRM \/ SuiteCRM - TechCRM<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Email Template With Attachment \u2013 SugarCRM \/ SuiteCRM - TechCRM\" \/>\n<meta property=\"og:description\" content=\"If user want email with attachment this can be done very easily in SugarCRM \/ SuiteCRM. Steps are as below, Step 1 : Get the Email Template detail using following code, Step 2 : Get the Attachments of Email Template using following code, Step 3 : Sending Email Code using following code, Hope you find [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/\" \/>\n<meta property=\"og:site_name\" content=\"TechCRM\" \/>\n<meta property=\"article:published_time\" content=\"2020-05-21T17:58:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-09-08T09:21:14+00:00\" \/>\n<meta name=\"author\" content=\"Navin Rakhonde\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Navin Rakhonde\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/\",\"name\":\"Email Template With Attachment \u2013 SugarCRM \/ SuiteCRM - TechCRM\",\"isPartOf\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\"},\"datePublished\":\"2020-05-21T17:58:55+00:00\",\"dateModified\":\"2020-09-08T09:21:14+00:00\",\"author\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.techcrm.in\/blogs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SugarCRM\",\"item\":\"https:\/\/www.techcrm.in\/blogs\/category\/sugarcrm\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Email Template With Attachment \u2013 SugarCRM \/ SuiteCRM\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/\",\"name\":\"TechCRM\",\"description\":\"Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.techcrm.in\/blogs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\",\"name\":\"Navin Rakhonde\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g\",\"caption\":\"Navin Rakhonde\"},\"sameAs\":[\"https:\/\/www.techcrm.in\/\"],\"url\":\"https:\/\/www.techcrm.in\/blogs\/author\/navin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Email Template With Attachment \u2013 SugarCRM \/ SuiteCRM - TechCRM","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/","og_locale":"en_US","og_type":"article","og_title":"Email Template With Attachment \u2013 SugarCRM \/ SuiteCRM - TechCRM","og_description":"If user want email with attachment this can be done very easily in SugarCRM \/ SuiteCRM. Steps are as below, Step 1 : Get the Email Template detail using following code, Step 2 : Get the Attachments of Email Template using following code, Step 3 : Sending Email Code using following code, Hope you find [&hellip;]","og_url":"https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/","og_site_name":"TechCRM","article_published_time":"2020-05-21T17:58:55+00:00","article_modified_time":"2020-09-08T09:21:14+00:00","author":"Navin Rakhonde","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Navin Rakhonde","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/","url":"https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/","name":"Email Template With Attachment \u2013 SugarCRM \/ SuiteCRM - TechCRM","isPartOf":{"@id":"https:\/\/www.techcrm.in\/blogs\/#website"},"datePublished":"2020-05-21T17:58:55+00:00","dateModified":"2020-09-08T09:21:14+00:00","author":{"@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc"},"breadcrumb":{"@id":"https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.techcrm.in\/blogs\/email-template-with-attachment-sugarcrm-suitecrm\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.techcrm.in\/blogs\/"},{"@type":"ListItem","position":2,"name":"SugarCRM","item":"https:\/\/www.techcrm.in\/blogs\/category\/sugarcrm\/"},{"@type":"ListItem","position":3,"name":"Email Template With Attachment \u2013 SugarCRM \/ SuiteCRM"}]},{"@type":"WebSite","@id":"https:\/\/www.techcrm.in\/blogs\/#website","url":"https:\/\/www.techcrm.in\/blogs\/","name":"TechCRM","description":"Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.techcrm.in\/blogs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc","name":"Navin Rakhonde","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g","caption":"Navin Rakhonde"},"sameAs":["https:\/\/www.techcrm.in\/"],"url":"https:\/\/www.techcrm.in\/blogs\/author\/navin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/321","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/comments?post=321"}],"version-history":[{"count":3,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/321\/revisions"}],"predecessor-version":[{"id":370,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/321\/revisions\/370"}],"wp:attachment":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/media?parent=321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/categories?post=321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/tags?post=321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}