<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: finding all the attachments in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/760688#M61693</link>
    <description>&lt;P&gt;Thank you for tagging&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074"&gt;@Jaycee_Lewis&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/517825"&gt;@rajeev-fas&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code should point you in the right direction:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import os
from pprint import pprint
from hubspot import HubSpot
from hubspot.crm.companies import ApiException as company_execption
from hubspot.crm.objects.notes import ApiException as engagement_exception
from dotenv import load_dotenv

load_dotenv()


hubspot = HubSpot(access_token=os.getenv("access_token"))
company_id = 5800956379  # ID of the company you want the attachments for
attachment_ids = []

# Attachments are tied to note engagments. Get all notes for the company

try:
    get_notes = hubspot.crm.companies.associations_api.get_all(
        company_id=company_id, to_object_type="note", limit=500
    )
    # pprint(get_notes.results) uncomment for debug

except company_execption as e:
    print("Exception when calling associations_api-&amp;gt;get_all: %s\n" % e)

# Iterate through all the note ids from the response and get their properties

for note in get_notes.results:
    try:
        get_note = hubspot.crm.objects.notes.basic_api.get_by_id(
            note_id=note.to_object_id, properties=["hs_attachment_ids"], archived=False
        )
        # pprint(get_note.properties) uncomment for debug

        attachment_id = get_note.properties["hs_attachment_ids"]

        # Check if the note has an attachment
        if attachment_id is not None:
            id_list = attachment_id.split(";")
            # pprint(id_list) uncomment for debug

            # Extend the list of attachments
            attachment_ids.extend(id_list)

    except engagement_exception as e:
        print("Exception when calling basic_api-&amp;gt;get_by_id: %s\n" % e)

# Print out the complete list of attachment ids. To download use /files/v3/files/{fileId} endpoint
pprint(attachment_ids)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you found this post helpful, consider helping others in the community to find answers faster by marking this as a solution. I'd really appreciate it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chriso&lt;/P&gt;</description>
    <pubDate>Fri, 24 Feb 2023 13:59:36 GMT</pubDate>
    <dc:creator>ChrisoKlepke</dc:creator>
    <dc:date>2023-02-24T13:59:36Z</dc:date>
    <item>
      <title>finding all the attachments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/760104#M61644</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking for a way to list out and download all the attachments associated to a company id using python api.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please guide me through how to do this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 12:55:58 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/760104#M61644</guid>
      <dc:creator>rajeev-fas</dc:creator>
      <dc:date>2023-02-23T12:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: finding all the attachments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/760474#M61682</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/517825"&gt;@rajeev-fas&lt;/a&gt;. I'd suggest starting out with the &lt;A href="https://developers.hubspot.com/docs/api/crm/search" target="_blank" rel="noopener"&gt;Search API documentation&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hey,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/241684"&gt;@ChrisoKlepke&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/133120"&gt;@MatthiasWeber&lt;/a&gt;&amp;nbsp;do either of you have a simple Python-based Search API example saved?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Jaycee&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 00:15:24 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/760474#M61682</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2023-02-24T00:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: finding all the attachments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/760534#M61688</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074"&gt;@Jaycee_Lewis&lt;/a&gt;&amp;nbsp;- no Python-knowledge. Sorry.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 06:54:14 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/760534#M61688</guid>
      <dc:creator>MatthiasWeber</dc:creator>
      <dc:date>2023-02-24T06:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: finding all the attachments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/760688#M61693</link>
      <description>&lt;P&gt;Thank you for tagging&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074"&gt;@Jaycee_Lewis&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/517825"&gt;@rajeev-fas&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code should point you in the right direction:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import os
from pprint import pprint
from hubspot import HubSpot
from hubspot.crm.companies import ApiException as company_execption
from hubspot.crm.objects.notes import ApiException as engagement_exception
from dotenv import load_dotenv

load_dotenv()


hubspot = HubSpot(access_token=os.getenv("access_token"))
company_id = 5800956379  # ID of the company you want the attachments for
attachment_ids = []

# Attachments are tied to note engagments. Get all notes for the company

try:
    get_notes = hubspot.crm.companies.associations_api.get_all(
        company_id=company_id, to_object_type="note", limit=500
    )
    # pprint(get_notes.results) uncomment for debug

except company_execption as e:
    print("Exception when calling associations_api-&amp;gt;get_all: %s\n" % e)

# Iterate through all the note ids from the response and get their properties

for note in get_notes.results:
    try:
        get_note = hubspot.crm.objects.notes.basic_api.get_by_id(
            note_id=note.to_object_id, properties=["hs_attachment_ids"], archived=False
        )
        # pprint(get_note.properties) uncomment for debug

        attachment_id = get_note.properties["hs_attachment_ids"]

        # Check if the note has an attachment
        if attachment_id is not None:
            id_list = attachment_id.split(";")
            # pprint(id_list) uncomment for debug

            # Extend the list of attachments
            attachment_ids.extend(id_list)

    except engagement_exception as e:
        print("Exception when calling basic_api-&amp;gt;get_by_id: %s\n" % e)

# Print out the complete list of attachment ids. To download use /files/v3/files/{fileId} endpoint
pprint(attachment_ids)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you found this post helpful, consider helping others in the community to find answers faster by marking this as a solution. I'd really appreciate it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chriso&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 13:59:36 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/760688#M61693</guid>
      <dc:creator>ChrisoKlepke</dc:creator>
      <dc:date>2023-02-24T13:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: finding all the attachments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/760778#M61697</link>
      <description>&lt;P&gt;Dang it,&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/133120"&gt;@MatthiasWeber&lt;/a&gt;! My brain knew that, but my fingers betrayed me &lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 16:29:21 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/760778#M61697</guid>
      <dc:creator>Jaycee_Lewis</dc:creator>
      <dc:date>2023-02-24T16:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: finding all the attachments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/760994#M61713</link>
      <description>&lt;P&gt;Hello Christoph,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I was able to run the above code but it does not return anything. I am using company_id which has 10+ attachements when I look into Hubspot portal.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The notes section for this company is empty in the portal. Since in the above code we are querying "notes", my question is are we using the right&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"to_object_type"&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you all for all the ongoing help with this.&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 25 Feb 2023 03:28:07 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/760994#M61713</guid>
      <dc:creator>rajeev-fas</dc:creator>
      <dc:date>2023-02-25T03:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: finding all the attachments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/761261#M61718</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/517825"&gt;@rajeev-fas&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in general, if you upload any attachments, a note gets created where the respective file can also be found. That is btw also the case when you create attachments through a form upload.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get to the file/s from the API, you have to go through the associated activities to find them. There is no&amp;nbsp;&lt;EM&gt;to_object_type&amp;nbsp;&lt;/EM&gt;called&amp;nbsp;&lt;EM&gt;attachments&amp;nbsp;&lt;/EM&gt;or something similar.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This might sound stupid, but maybe you're currently filtering notes in the activities when looking at the record.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now, it is hard for us to diagnose these things at a distance. So without any more information, it will be very hard for us to help you any further. For example: How are these attachments created in the first place?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Chriso&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 07:45:28 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/761261#M61718</guid>
      <dc:creator>ChrisoKlepke</dc:creator>
      <dc:date>2023-02-27T07:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: finding all the attachments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/761408#M61733</link>
      <description>&lt;P&gt;Thank you Chriso, you put me in the right track. Here is the complete code which will find all the email attachments by company id.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; hubspot &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; HubSpot&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; hubspot.crm.companies &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; ApiException &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt; company_execption&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; hubspot.crm.objects.notes &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; ApiException &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt;&lt;SPAN&gt; engagement_exception&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt;&lt;SPAN&gt; dotenv &lt;/SPAN&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; load_dotenv&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;os&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt; &lt;SPAN&gt;pprint&lt;/SPAN&gt; &lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;pprint&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;requests&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;mimetypes&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;gzip&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;json&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt; &lt;SPAN&gt;urllib&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;parse&lt;/SPAN&gt; &lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;unquote&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;csv&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;from&lt;/SPAN&gt; &lt;SPAN&gt;datetime&lt;/SPAN&gt; &lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;datetime&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;random&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;string&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;access_token&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;"YourAccessToken"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;company_id = "YourCompanyID"&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;hubspot&lt;/SPAN&gt;&lt;SPAN&gt; = HubSpot(&lt;/SPAN&gt;&lt;SPAN&gt;access_token&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;access_token&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;attachment_ids&lt;/SPAN&gt;&lt;SPAN&gt; = [] &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;# email attachments &amp;nbsp; &amp;nbsp; are tied to email engagments. Get all emails for the company&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;get_emails&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;hubspot&lt;/SPAN&gt;&lt;SPAN&gt;.crm.companies.associations_api.get_all(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;company_id&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;company_id&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;to_object_type&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"EMAIL"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;limit&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;500&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;#pprint(get_emails.results) #uncomment for debug&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;except&lt;/SPAN&gt;&lt;SPAN&gt; company_execption &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt; &lt;SPAN&gt;e&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"Exception when calling associations_api-&amp;gt;get_all: &lt;/SPAN&gt;&lt;SPAN&gt;%s&lt;/SPAN&gt;&lt;SPAN&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt; % &lt;/SPAN&gt;&lt;SPAN&gt;e&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;for&lt;/SPAN&gt; &lt;SPAN&gt;email&lt;/SPAN&gt; &lt;SPAN&gt;in&lt;/SPAN&gt; &lt;SPAN&gt;get_emails&lt;/SPAN&gt;&lt;SPAN&gt;.results:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;get_email&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;hubspot&lt;/SPAN&gt;&lt;SPAN&gt;.crm.objects.emails.basic_api.get_by_id(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;email_id&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;email&lt;/SPAN&gt;&lt;SPAN&gt;.to_object_id, &lt;/SPAN&gt;&lt;SPAN&gt;properties&lt;/SPAN&gt;&lt;SPAN&gt;=[&lt;/SPAN&gt;&lt;SPAN&gt;"hs_attachment_ids"&lt;/SPAN&gt;&lt;SPAN&gt;], &lt;/SPAN&gt;&lt;SPAN&gt;archived&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;False&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;# pprint(get_email.properties) uncomment for debug&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;attachment_id&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;get_email&lt;/SPAN&gt;&lt;SPAN&gt;.properties[&lt;/SPAN&gt;&lt;SPAN&gt;"hs_attachment_ids"&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;# Check if the email has an attachment&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt; &lt;SPAN&gt;attachment_id&lt;/SPAN&gt; &lt;SPAN&gt;is&lt;/SPAN&gt; &lt;SPAN&gt;not&lt;/SPAN&gt; &lt;SPAN&gt;None&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;id_list&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;attachment_id&lt;/SPAN&gt;&lt;SPAN&gt;.split(&lt;/SPAN&gt;&lt;SPAN&gt;";"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;# Extend the list of attachments&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;attachment_ids&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;extend&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;id_list&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;except&lt;/SPAN&gt;&lt;SPAN&gt; engagement_exception &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt; &lt;SPAN&gt;e&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"Exception when calling basic_api-&amp;gt;get_by_id: &lt;/SPAN&gt;&lt;SPAN&gt;%s&lt;/SPAN&gt;&lt;SPAN&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt; % &lt;/SPAN&gt;&lt;SPAN&gt;e&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;attachment_ids&lt;/SPAN&gt;&lt;SPAN&gt; = [&lt;/SPAN&gt;&lt;SPAN&gt;x&lt;/SPAN&gt; &lt;SPAN&gt;for&lt;/SPAN&gt; &lt;SPAN&gt;x&lt;/SPAN&gt; &lt;SPAN&gt;in&lt;/SPAN&gt; &lt;SPAN&gt;attachment_ids&lt;/SPAN&gt; &lt;SPAN&gt;if&lt;/SPAN&gt; &lt;SPAN&gt;x&lt;/SPAN&gt;&lt;SPAN&gt; != &lt;/SPAN&gt;&lt;SPAN&gt;''&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;len&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;attachment_ids&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 27 Feb 2023 13:29:07 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/761408#M61733</guid>
      <dc:creator>rajeev-fas</dc:creator>
      <dc:date>2023-02-27T13:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: finding all the attachments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/761424#M61735</link>
      <description>&lt;P&gt;Glad I was able to help &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Feb 2023 13:53:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/761424#M61735</guid>
      <dc:creator>ChrisoKlepke</dc:creator>
      <dc:date>2023-02-27T13:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: finding all the attachments</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/850086#M67493</link>
      <description>&lt;P&gt;Hey there!&lt;/P&gt;
&lt;P&gt;We've just released the Attachment From Form app on the HubSpot Marketplace!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're tired of playing hide-and-seek with files in your HubSpot database, you're in the right place! Attachment From Form simplifies the process by linking files submitted in a form directly to the corresponding contact record. Say goodbye to the endless file hunt and say hello to effortless access!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are the standout features:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Effortless Form-Attachment Connection: Easily link your forms to contact attachments.&lt;/P&gt;
&lt;P&gt;2. Efficient File Retrieval: When a contact submits a file type property in your form, it appears in the attachment card, saving you valuable time.&lt;/P&gt;
&lt;P&gt;3. Organized Activity Section: Attachment From Form creates custom activities, making it a breeze to find attached files on the contact page while maintaining a comprehensive property attribution history.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Get organized and supercharge your efficiency with the Attachment From Form app now! And the best part? It won't cost you a dime.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;You can install it right away -&amp;gt;&amp;nbsp;&lt;A class="" href="https://ecosystem.hubspot.com/marketplace/apps/marketing/data-management/attachment-from-form-1752956" target="_blank" rel="noopener"&gt;LINK&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2023 12:38:50 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/finding-all-the-attachments/m-p/850086#M67493</guid>
      <dc:creator>Franci</dc:creator>
      <dc:date>2023-09-15T12:38:50Z</dc:date>
    </item>
  </channel>
</rss>

