Answers.Body: <p>@Sudesh After apply the patch, I used a token, because i needed a custom field in the image, maybe works for you(the answer don't fit in comment :S)</p>
  
  <p>The cid require a mail format for example foo@ba.org</p>
  
  <pre><code>hook_civicrm_tokenValues( &amp;$values, $cids, $job = null, $tokens = array(), $context = null ) {
  ...
   $values[$key]["xxx.app_signature"] = '&lt;img alt="Embedded Image" src="cid:foo@ba.org" &gt;' . '&lt;tagimagetoken&gt;' . $config-&gt;customFileUploadDir . $result_image["uri"] . '&lt;/tagimagetoken&gt;';
  </code></pre>
  
  <p>And later replace the token with correct value in the mail hook</p>
  
  <pre><code>hook_civicrm_alterMailParams(&amp;$params, $context) {  
    $regex = "/&lt;\s*tagimagetoken[^&gt;]*&gt;([^&lt;]*)&lt;\s*\/\s*tagimagetoken\s*&gt;/";
    preg_match_all($regex, $params["html"], $output);      
    if(isset($output[1][0])) {  
      $params["html"] = preg_replace ( $regex , "" ,  $params["html"]); 
      $params["attachments"][] =  array(
        'fullPath' =&gt; $output[1][0],      
        'content_id' =&gt; "foo@ba.org",
        'c_type' =&gt; "image/png",
        'is_file' =&gt; TRUE,
        'is_image' =&gt; TRUE,
      );      
    }   
  }
  </code></pre>
  
  <p>And in the email put the token </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-18T09:47:12.223Z
Answers.Text: Ok. Correct me if I misunderstand, but, you insert this custom token whenever you want an in-line image in the HTML email and the token is replaced in the hook. So, how does it work when you now composing the email in CKEditor and you want to add some in-line image to the email?
Answers.UserDisplayName: Sudesh
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-20T10:17:19.963Z
Answers.Text: This solutions it's creating a token, when you create a token later appear when you compose a email clicking in "Insert token".
  
  If the image that you want add is not in the contact(fixed for all mails).  You can add directly in the email with source "<img alt="Embedded Image" src="cid:foo@ba.org" >" and only make the step  "hook_alterMailParams."  inserting the $params["attachments"][].
Answers.UserDisplayName: rubofvil
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-16T22:19:01.450Z
Answers.LastActivityDate: 2015-11-16T22:19:01.450Z
Answers.UserDisplayName: rubofvil
Answers.Body: <p>In package Mail exist the method "addHTMLImage"
  <a href="https://github.com/civicrm/civicrm-packages/blob/master/Mail/mime.php#L332" rel="nofollow">https://github.com/civicrm/civicrm-packages/blob/master/Mail/mime.php#L332</a></p>
  
  <p>The patch fix in the actions contact  "Send a email"(not in component civimail).<a href="https://github.com/rubofvil/civicrm-core/commit/aa11061457da792f6678786ede446422fc450e36" rel="nofollow">https://github.com/rubofvil/civicrm-core/commit/aa11061457da792f6678786ede446422fc450e36</a></p>
  
  <p>I'm sending the parameters in the hook_civicrm_alterMailParams</p>
  
  <pre><code>$params["attachments"][] =  array(
    'fullPath' =&gt; $output[1][0],      
    'content_id' =&gt; "attachmentsignature",
    'c_type' =&gt; "image/png",
    'is_file' =&gt; TRUE,
    'is_image' =&gt; TRUE,
  );      
  </code></pre>
  
  <p>Next Issue: With the patch CiviMail put in content-id the email in some point. The image it's attached inline but with incorrect content-id.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-13T10:07:01.037Z
Answers.Text: Hi rubofvil, have you manged to get around the incorrect content ID? I'm also wanting to embed images using content ID for our mail campaigns using Civimail. WIthout using CID, Outlook will always block these images. Mail clients like SendinBlue use CID and Outlook displays images perfectly with images sent from SendinBlue.
Answers.UserDisplayName: Sudesh
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-11-16T22:22:29.673Z
Answers.Text: @Sudesh, I answered in another answer, here don't fit the solution
Answers.UserDisplayName: rubofvil
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-14T08:55:51.527Z
Answers.Text: do you have a full patch that can be applied with the with the Token and the mail hook? Would you be able to share your entire source changes? We are really desperate on our side to get this working? I would really appreciate your help?
Answers.UserDisplayName: Sudesh
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-03T10:09:48.847Z
Answers.LastActivityDate: 2015-09-03T10:09:48.847Z
Answers.UserDisplayName: rubofvil
Body: <p>I need to add image(no public) in a email. Initially I tried "Inline Embedding" but gmail, ... block the images, now I'm trying to add with "CID Embedded Images"</p>
  
  <p>Exist some way to add the Content-ID in the attached files.</p>
  
  <p><code>
  $params["attachments"][] =  array(
        'fullPath' => $output,
        'Content-ID' => 'attachementsignature' //Something like that
      );
  </code>    </p>
  
  <p>Info "Inline Embedding", "CID Embedded Images" in
  <a href="https://sendgrid.com/blog/embedding-images-emails-facts/" rel="nofollow">https://sendgrid.com/blog/embedding-images-emails-facts/</a></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-09-02T15:53:51.870Z
Comments.Text: Patch to try fix the issue.
  
  https://github.com/rubofvil/civicrm-core/commit/aa11061457da792f6678786ede446422fc450e36.patch
Comments.UserDisplayName: rubofvil
Tags: <civimail>
Title: "Content-ID" in email attachments
ThreadText: # "Content-ID" in email attachments
  
  (Asked by: username_0 on 2015-08-31)
  
  I need to add image(no public) in a email. Initially I tried "Inline Embedding" but gmail, ... block the images, now I'm trying to add with "CID Embedded Images"
  
  Exist some way to add the Content-ID in the attached files.
  
  `$params["attachments"][] = array(
  'fullPath' => $output,
  'Content-ID' => 'attachementsignature' //Something like that
  );`
  
  Info "Inline Embedding", "CID Embedded Images" in
  <https://sendgrid.com/blog/embedding-images-emails-facts/>
  
  **Tags:** civimail
  
  > **Comments:**
  > **username_0**: Patch to try fix the issue.  https://github.com/username_0/civicrm-core/commit/aa11061457da792f6678786ede446422fc450e36.patch  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2015-11-16. Score: 1
  
  @username_1 After apply the patch, I used a token, because i needed a custom field in the image, maybe works for you(the answer don't fit in comment :S)
  
  The cid require a mail format for example foo@ba.org
  
  ```
  hook_civicrm_tokenValues( &$values, $cids, $job = null, $tokens = array(), $context = null ) {
  ...
   $values[$key]["xxx.app_signature"] = '<img alt="Embedded Image" src="cid:foo@ba.org" >' . '<tagimagetoken>' . $config->customFileUploadDir . $result_image["uri"] . '</tagimagetoken>';
  
  ```
  
  And later replace the token with correct value in the mail hook
  
  ```
  hook_civicrm_alterMailParams(&$params, $context) {  
    $regex = "/<\s*tagimagetoken[^>]*>([^<]*)<\s*\/\s*tagimagetoken\s*>/";
    preg_match_all($regex, $params["html"], $output);      
    if(isset($output[1][0])) {  
      $params["html"] = preg_replace ( $regex , "" ,  $params["html"]); 
      $params["attachments"][] =  array(
        'fullPath' => $output[1][0],      
        'content_id' => "foo@ba.org",
        'c_type' => "image/png",
        'is_file' => TRUE,
        'is_image' => TRUE,
      );      
    }   
  }
  
  ```
  
  And in the email put the token
  
  > **Comments:**
  > **username_1**: Ok. Correct me if I misunderstand, but, you insert this custom token whenever you want an in-line image in the HTML email and the token is replaced in the hook. So, how does it work when you now composing the email in CKEditor and you want to add some in-line image to the email?  
  > **username_0**: This solutions it's creating a token, when you create a token later appear when you compose a email clicking in "Insert token".  If the image that you want add is not in the contact(fixed for all mails).  You can add directly in the email with source "<img alt="Embedded Image" src="cid:foo@ba.org" >" and only make the step  "hook_alterMailParams."  inserting the $params["attachments"][].  
  
  ---
  
  ### Answer by username_0 on 2015-09-03. Score: 0
  
  In package Mail exist the method "addHTMLImage"
  <https://github.com/civicrm/civicrm-packages/blob/master/Mail/mime.php#L332>
  
  The patch fix in the actions contact "Send a email"(not in component civimail).<https://github.com/username_0/civicrm-core/commit/aa11061457da792f6678786ede446422fc450e36>
  
  I'm sending the parameters in the hook\_civicrm\_alterMailParams
  
  ```
  $params["attachments"][] =  array(
    'fullPath' => $output[1][0],      
    'content_id' => "attachmentsignature",
    'c_type' => "image/png",
    'is_file' => TRUE,
    'is_image' => TRUE,
  );      
  
  ```
  
  Next Issue: With the patch CiviMail put in content-id the email in some point. The image it's attached inline but with incorrect content-id.
  
  > **Comments:**
  > **username_1**: Hi username_0, have you manged to get around the incorrect content ID? I'm also wanting to embed images using content ID for our mail campaigns using Civimail. WIthout using CID, Outlook will always block these images. Mail clients like SendinBlue use CID and Outlook displays images perfectly with images sent from SendinBlue.  
  > **username_0**: @username_1, I answered in another answer, here don't fit the solution  
  > **username_1**: do you have a full patch that can be applied with the with the Token and the mail hook? Would you be able to share your entire source changes? We are really desperate on our side to get this working? I would really appreciate your help?  
  
  ---
  
  