Is there anyone who could tell me how to retrieve an Email from Salesforce Marketing Cloud?
Assume that the Marketing Cloud Connector is already OK.
Is there anyone who could tell me how to retrieve an Email from Salesforce Marketing Cloud?
Assume that the Marketing Cloud Connector is already OK.
I used the soap api of Marketing Cloud to fetched emails of MC, and the following is my solution:
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('https://webservice.s7.exacttarget.com/Service.asmx');
req.setMethod('POST');
req.setHeader('Content-Type', 'text/xml;charset=UTF-8');
req.setHeader('SOAPAction', 'Retrieve');
String eBody = '';
eBody += '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
eBody += '<soapenv:Header>';
eBody += '<wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">';
eBody += '<wsse:UsernameToken wsu:Id="UsernameToken-32259181" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">';
eBody += '<wsse:Username>SFMC Connector API User</wsse:Username>';
eBody += '<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">yourpassword</wsse:Password>';
eBody += '</wsse:UsernameToken>';
eBody += '</wsse:Security>';
eBody += '</soapenv:Header>';
eBody += '<soapenv:Body>';
eBody += '<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">';
eBody += '<RetrieveRequest>';
eBody += '<ObjectType>Email</ObjectType>';
eBody += '<Properties>ID</Properties>';
eBody += '<Properties>Name</Properties>';
eBody += '<Properties>Subject</Properties>';
eBody += '<Properties>ContentAreas</Properties>';
eBody += '<Properties>HTMLBody</Properties>';
// If need a filter
eBody += '<Filter xsi:type="SimpleFilterPart">';
eBody += '<Property>ID</Property>';
eBody += '<SimpleOperator>equals</SimpleOperator>';
eBody += '<Value>12345</Value>';
eBody += '</Filter>';
eBody += '</RetrieveRequest>';
eBody += '</RetrieveRequestMsg>';
eBody += '</soapenv:Body>';
eBody += '</soapenv:Envelope>';
req.setBody(eBody);
req.setTimeout(120000);
HttpResponse res = http.send(req);
System.debug('qqqq res.getBody=' + res.getBody());
Hope this can help someone!