0

We have been sending emails and SMSes from Service Cloud through marketing Cloud.We are just using SFMC as a gateway and using its Transactional API to send the emails and SMSes.We are building the content/body in service cloud and sending in the payload to Transactional API. Now we want to send Attachments in the email/SMSes .Is it possible to do it via transactional API. How can i send attachments from Service cloud in the payload? Any immediate help is much appreciated. This is how we are preparing the payload in SFDC.

                    'to' => em.recipient,
                    'contactKey' => em.contactKey,
                    'attributes' => new Map<String, Object> {
                            'HTMLContent' => em.content,
                            'Subject' => em.subject
                    }   
            };
            recipients.add(recipient);
        }
        Map<String, Object> requestBody = new Map<String, Object>{
                'definitionKey' => sendDefinition,
                'recipients' => recipients
        };
        return requestBody

1 Answer 1

3

There is no support for attaching files in the endpoints for neither the classic Triggered Send nor for the new Transactional Messaging API. Hence you will need to use Ampscript within the email itself to request the file and attach it. As outlined in this and numerous other threads on file attachments in Marketing Cloud, you can use the AttachFile function in Ampscript. This goes across both transactional and marketing emails. Here is an example:

%%=AttachFile('HTTP','http://example.com/catalog.pdf','newFileName.pdf',true,'http://example.com/catalog.pdf','Click here to download your catalog',4)=%%

The challenge in your case is, assuming, exposing the file in Service Cloud in a way, so it can be fetched over HTTP. You can start by ensuring Public Links are enabled in your Org. Once a file is publicly accessible, you can attach it using above function.

Keep me posted on how you will implement the file attachment in your SMS messages, I'm quite curious here.

3
  • Thanks @Lukas Lunow .I am sorry but I do not clearly understand .We are only using SFMC as a gateway.The email body and everything is prepared in Service cloud(As i have now updated in the post above) and the content is sent in the payload.Now those emails in Service cloud will contain attachments.We are not using marketing cloud templates(where we can use AMPScript) or anything from marketing cloud.
    – Chetan
    Commented Sep 18, 2020 at 12:38
  • @Chetan - I have updated the answer to be more precise. There is no support for attaching files using any of the APIs for transactional emails. So your only way is to utilise the Ampscript function. Commented Sep 18, 2020 at 12:43
  • Thanks @Lukas , will surely update here. Just to clarify a little,we can use AMPscript function in the email templates content that we are preparing in Service cloud. We are not touching Marketing cloud for any template preparation.So you are saying we should prepare the templates in Marketing cloud and use AMPScript there to the fetch the Service cloud exposed pdf?
    – Chetan
    Commented Sep 18, 2020 at 12:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .