Answers.Body: <p>Would <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_emailProcessor/" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_emailProcessor/</a> work? It will let you update the assignee on the activity after it gets saved.</p>
  <p>e.g.</p>
  <pre><code>function myextension_civicrm_emailProcessor( $type, &amp;$params, $mail, &amp;$result, $action = null ) {
    if ($type != 'activity') {
      return;
    }
    $contact_id = 36377; // this is contact C
    $params = array(
      1 =&gt; array($contact_id, 'Integer'),
      2 =&gt; array($result['id'], 'Integer'),
      3 =&gt; array(CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Assignees'), 'Integer'),
    );
    CRM_Core_DAO::executeQuery(&quot;UPDATE civicrm_activity_contact SET contact_id = %1 WHERE activity_id = %2 AND record_type_id=%3&quot;, $params);
    // or use api if preferred
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-18T15:55:41.237Z
Answers.Text: thanks Dave, this means I don't need to dig further in some hidden front setting. We'll use this hook instead.
Answers.UserDisplayName: Guillaume Sorel
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-18T14:30:10.243Z
Answers.LastActivityDate: 2022-01-18T14:30:10.243Z
Answers.UserDisplayName: Demerit
Body: <p>We're trying the inbound e-mail to activity functionality and it works fine.</p>
  <p>The only limitation until now is that the 'source' and 'assigned to' contact seems to be the same.</p>
  <p>We need to have a process that adds an activity assigned to 'C', created by 'A' with contact 'B'.</p>
  <p>Is this possible out of the box? Would you use a CiviRule to change assignee?</p>
  <p>(we've been through documentation and SE and couldn't find such a situation, that seemed at first obvious to me)</p>
  
Tags: <inbound-email>
Title: 'Assigned to' option in Inbound e-mails
ThreadText: # 'Assigned to' option in Inbound e-mails
  
  (Asked by: username_0 on 2022-01-18)
  
  We're trying the inbound e-mail to activity functionality and it works fine.
  
  The only limitation until now is that the 'source' and 'assigned to' contact seems to be the same.
  
  We need to have a process that adds an activity assigned to 'C', created by 'A' with contact 'B'.
  
  Is this possible out of the box? Would you use a CiviRule to change assignee?
  
  (we've been through documentation and SE and couldn't find such a situation, that seemed at first obvious to me)
  
  **Tags:** inbound-email
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-01-18. Score: 1
  
  Would <https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_emailProcessor/> work? It will let you update the assignee on the activity after it gets saved.
  
  e.g.
  
  ```
  function myextension_civicrm_emailProcessor( $type, &$params, $mail, &$result, $action = null ) {
    if ($type != 'activity') {
      return;
    }
    $contact_id = 36377; // this is contact C
    $params = array(
      1 => array($contact_id, 'Integer'),
      2 => array($result['id'], 'Integer'),
      3 => array(CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Assignees'), 'Integer'),
    );
    CRM_Core_DAO::executeQuery("UPDATE civicrm_activity_contact SET contact_id = %1 WHERE activity_id = %2 AND record_type_id=%3", $params);
    // or use api if preferred
  }
  
  ```
  
  > **Comments:**
  > **username_0**: thanks Dave, this means I don't need to dig further in some hidden front setting. We'll use this hook instead.  
  
  ---
  
  