0

i'm trying to get the Email Templates from SFMC using Apex. I understand that the SOAP Api of SFMC has to be used but i don't know how to call it to retrieve the email templates. By the way, I try this example to connect to SFMC using SOAP: Making a callout in Apex to Marketing Cloud SOAP API and it works great.

Thank you!

1 Answer 1

0

Use SOAP API to retrieve email from Classic Tool:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
    <fueloauth>YOUR_TOKEN_HERE</fueloauth>
</Header>
<Body>
    <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
        <RetrieveRequest>
            <ObjectType>Email</ObjectType>
            <Properties>ID</Properties>
            <Properties>Name</Properties>
            <Properties>Subject</Properties>
            <Properties>Status</Properties>
            <Properties>PartnerKey</Properties>
            <Properties>CreatedDate</Properties>
            <Properties>Folder</Properties>
            <Properties>CategoryID</Properties>
            <Properties>EmailType</Properties>
            <Properties>HTMLBody</Properties>
            <Properties>ContentAreas</Properties>
            <Filter xsi:type="SimpleFilterPart">
                <Property>Id</Property>
                <SimpleOperator>equals</SimpleOperator>
                <Value>{EMAIL_ID_HERE}</Value>
            </Filter>
        </RetrieveRequest>
    </RetrieveRequestMsg>
</Body>

Remove filter part to retrieve all emails or filter by CategoryId as @pkharries suggested

ID can be found in email properties.
classic content id


Use REST API to retrieve email from Content Builder:

https://www.exacttargetapis.com/asset/v1/content/assets/{id}

GET /asset/v1/content/assets/{EMAIL_ID_HERE} HTTP/1.1
Host: www.exacttargetapis.com
Authorization: Bearer YOUR_TOKEN_HERE
Content-Type: application/json

Or retrieve all assets (filter by name for example):

GET /asset/v1/content/assets?$filter=Name%20like%20'Template' 
HTTP/1.1
Host: www.exacttargetapis.com
Authorization: Bearer YOUR_TOKEN_HERE
Content-Type: application/json

ID can be found in email properties.
enter image description here

7
  • Thanks for the answer, but this example is for retrieve one specific Email Template, isn't it? I want to retrieve all the Email Templates from SFMC, it's that possible? I also don't see where to find de Email id. Regards
    – Alvaro
    Jun 18, 2018 at 20:56
  • @Alvaro By Using CategoryId of Email Folder you can Retrieve All Emails At a time use like this in filter part <Filter xsi:type="SimpleFilterPart"> <Property>CategoryID</Property> <SimpleOperator>equals</SimpleOperator> <Value>61324</Value> </Filter>
    – Ravi.A
    Jun 19, 2018 at 9:52
  • Or just remove Filter part from the request Jun 19, 2018 at 9:55
  • @Alvaro please check updated answer with additional information for retrieving list of emails Jun 19, 2018 at 10:30
  • Great answer @matrosik, i can retrieve the email templates with the examples given! Thank you very much
    – Alvaro
    Jun 19, 2018 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.