title: How to attach file to email using REST API
body: <p>I am working with emails from REST API.<br>
  I am able to create the email in the system and to update it.<br>
  The problem is with attaching files to the email to correct the images in the body of the email.   </p>
  
  <p>The endpoint for attaching files to records looks like below:</p>
  
  <p><code>http://&lt;Base endpoint URL&gt;/&lt;Top-level entity&gt;/&lt;Key value 1&gt;/&lt;Key value 2&gt;/files/&lt;File name&gt;</code></p>
  
  <p>The problem with emails is that the Key for emails is the NoteID field which can be accessed only using $custom parameter with requests like below:</p>
  
  <p><code>https://baseurl/18.200.001/Email?$filter=From eq 'test@email.com'&amp;$custom=Message.NoteID</code></p>
  
  <p>This request will return a response like below</p>
  
  <pre><code>[
      {
          "id": "50bd83f1-b5bb-49f2-8ca9-6e55d6e10463",
          "rowNumber": 1,
          "note": "",
          ...
          ...
          ...
          "custom": {
              "Message": {
                  "NoteID": {
                      "type": "CustomGuidField",
                      "value": "9daca267-4bbd-e911-81ee-0259459e71e6"
                  }
              }
          },
          "files": []
      }
  ]
  </code></pre>
  
  <p>Where the NoteID corresponds to the one shown in the browser URL for the email
  <a href="https://i.stack.imgur.com/VWWtx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VWWtx.png" alt="enter image description here"></a></p>
  
  <p>The problem is that when I try to send a request for attaching a file to that email using that NoteID or id from the response I always receive 'No entity satisfies the condition." error message in the request profiler.</p>
  
  <p>Is there any other way to attach files using REST API? </p>