0

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.

3
  • If you'd like the community to help you out, you're going to have to supply more details. What have you tried? Any code you can post? Oct 22 '15 at 15:22
  • Thx Adam! I had already got the answer by seached the soap api and asked my mate.
    – Leisure
    Oct 23 '15 at 6:15
  • Care to share a generic version of your solution? Oct 23 '15 at 11:18
2

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!

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.