Skip to content

Instantly share code, notes, and snippets.

@jacksonpchen
jacksonpchen / add-to-publication-list
Last active December 2, 2020 05:08
Add to Publication List
/*
AMPscript.com
*/
SET @rr = CreateObject("RetrieveRequest")
SetObjectProperty(@rr, "ObjectType", "List")
AddObjectArrayItem(@rr,"Properties","ListName")
AddObjectArrayItem(@rr,"Properties","ID")
@jacksonpchen
jacksonpchen / gmail-deal-badge
Last active December 2, 2020 05:10
Gmail Promotions Tab Deal Badge
<!-- Deal Badge -->
<!-- AMPscript.com -->
<!-- https://ampscript.com/company-logo-in-gmail-using-promotions-tab/ -->
<div itemscope="" itemtype="http://schema.org/DiscountOffer">
<meta itemprop="description" content="AMPscript.com">
<meta itemprop="discountCode" content="AMPSCRIPT">
<meta itemprop="availabilityStarts" content="2020-03-10T00:00:00Z">
<meta itemprop="availabilityEnds" content="2020-04-05T00:00:00Z">
</div>
@jacksonpchen
jacksonpchen / gmail-custom-logo
Last active December 2, 2020 05:10
Gmail Promotions Tab Custom Logo
/*
AMPscript.com
https://ampscript.com/parsing-json-with-ampscript/
*/
%%[ set @JSON = '{"name": AMPscript.com","email": "AMPscript@ampscript.com"}' ]%%
<!doctype html>
<html>
<head>
<meta charset="utf-8">
/*
AMPscript.com
https://ampscript.com/company-logo-in-gmail-using-promotions-tab/
*/
%%[
SET @JSONStart = Concat('<', 'script type="', 'application/ld+json"','>')
SET @JSONEnd = Concat('<','/','script','>')
]%%
%%=TreatAsContent(@JSONStart)=%%
[{
@jacksonpchen
jacksonpchen / ssjs-run-automation
Last active January 12, 2023 15:05
Marketing Cloud SSJS Run Automation
/*
AMPscript.com
https://ampscript.com/how-to-run-automations-more-frequently-using-ssjs/
*/
<script runat="server">
Platform.Load("Core","1.1.1");
var automationCustomerKey = "[Customer Key Goes Here]"
var rr = Platform.Function.CreateObject("RetrieveRequest");
Platform.Function.SetObjectProperty(rr, "ObjectType", "Automation");
Platform.Function.AddObjectArrayItem(rr, "Properties", "ProgramID");
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<fueloauth xmlns="http://exacttarget.com">[access_token_goes_here]</fueloauth>
</s:Header>
<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
<RetrieveRequest>
<ObjectType>DataExtensionField</ObjectType>
<Properties>Name</Properties>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<env:Header xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<wsa:Action>RetrieveResponse</wsa:Action>
<wsa:MessageID>urn:uuid:5f27fe84-7193-1eb4-868c-1b267866a0ez</wsa:MessageID>
<wsa:RelatesTo>urn:uuid:1e5fa6d1-eee5-1f72-a620-8c600c75d93s</wsa:RelatesTo>
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
<wsse:Security>
<wsu:Timestamp wsu:Id="Timestamp-c669d2bf-22a6-4e7f-b570-4b8bdc88361f">
<wsu:Created>2023-06-14T23:11:57Z</wsu:Created>
<wsu:Expires>2023-06-14T23:16:57Z</wsu:Expires>
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<fueloauth xmlns="http://exacttarget.com">[access_token_here]</fueloauth>
</s:Header>
<s:Body xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
<RetrieveRequest>
<ObjectType>DataExtensionField</ObjectType>
<Properties>Name</Properties>
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<fueloauth xmlns="http://exacttarget.com">[access_token_goes_here]</fueloauth>
<a:Action s:mustUnderstand="1">Delete</a:Action>
<a:MessageID>urn:uuid:d5c8c2ee-384e-4492-af18-b01e0d438b62</a:MessageID>
<a:ReplyTo>
<a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address>
</a:ReplyTo>
<a:To s:mustUnderstand="1">https://[unique_key_for_installed_package].soap.marketingcloudapis.com/Service.asmx</a:To>