Skip to content

Instantly share code, notes, and snippets.

View nmaratasdev's full-sized avatar

Nolan Maratas nmaratasdev

View GitHub Profile
@nmaratasdev
nmaratasdev / ampscript-dynamic-sender-profile-configuration.amp
Created May 25, 2022 18:55
ampscript-dynamic-sender-profile-configuration
%%=TreatAsContent(ContentBlockByKey('DynamicFromName'))=%%
%%=TreatAsContent(ContentBlockByKey('DynamicFromEmail'))=%%
@nmaratasdev
nmaratasdev / ampscript-dynamic-sender-profile-dynamic-from-email.amp
Created May 25, 2022 18:53
ampscript-dynamic-sender-profile-dynamic-from-email
%%[
/**
* Dynamic From Email Logic
* Use subscribers [language] preference from the entry DE to pull back dynamic fromEmail from the content DE.
*/
SET @language = AttributeValue("language")
SET @fromEmail = Lookup("ENT.04_DynamicSenderProfile_Content","fromEmail","language", @language)
]%%%%=v(@fromEmail)=%%
@nmaratasdev
nmaratasdev / ampscript-dynamic-sender-profile-dynamic-from-name.amp
Created May 25, 2022 18:52
ampscript-dynamic-sender-profile-dynamic-from-name
%%[
/**
* Dynamic From Name Logic
* Use subscribers [language] preference from the entry DE to pull back dynamic fromName from the content DE.
*/
SET @language = AttributeValue("language")
SET @fromName = Lookup("ENT.04_DynamicSenderProfile_Content","fromName","language", @language)
]%%%%=v(@fromName)=%%
@nmaratasdev
nmaratasdev / ampscript-looping-sample-xml-schema.xml
Created January 20, 2022 17:02
ampscript-looping-sample-xml-schema
<?xml version='1.0' encoding='UTF-8'?>
<catalog>
<book>
<id>001</id>
<author>Liu Cixin</author>
<title>The Three-Body Problem</title>
<genre>Science Fiction</genre>
</book>
<book>
<id>002</id>
@nmaratasdev
nmaratasdev / ampscript-looping-through-xml.amp
Created January 20, 2022 16:45
ampscript-looping-through-xml
<!-- Example Code -->
%%[
/**
* Looping Through XML Payload Data Demo
* This example consumes the XML payload that's stored in the [XML] field.
* This example loops through all <book> nodes and renders book details in the email.
* This example uses RaiseError() when there is no xml payload data to parse.
* This example uses RaiseError() when there are no <book> in the xml payload.
*/
SET @XML = [XML]
@nmaratasdev
nmaratasdev / ampscript-lookuprows-function-intermediate.amp
Last active September 29, 2022 15:59
ampscript-lookuprows-function-intermediate
<!-- Example Code -->
%%[
/**
* Basic Subscriber Variables
* Subscriber details from the sendable DE.
*/
SET @email_address = [email_address]
SET @language = [language]
SET @first_name = AttributeValue("first_name")
IF EMPTY(@first_name) THEN
@nmaratasdev
nmaratasdev / ampscript-format-functions-format-number.amp
Created December 18, 2021 10:04
ampscript-format-functions-format-number
<!-- Example Code -->
%%[
/**
* Format Number Logic
* Formats a specified string as a number value for a specified format or locale.
*/
VAR @number, @currency_english, @currency_french, @decimal, @fixed, @percent, @general
SET @number = "199"
SET @currency_english = FormatNumber(@number, "C", "en-us")
SET @currency_french = FormatNumber(@number, "C", "fr-fr")
@nmaratasdev
nmaratasdev / ampscript-format-functions-format-date.amp
Created December 18, 2021 10:04
ampscript-format-functions-format-date
<!-- Example Code -->
%%[
/**
* Format Date Logic
* Formats a specified string as a date value for a specified format and locale.
*/
VAR @date, @date_english, @date_spanish, @date_french, @date_chinese
SET @date = "2012-10-05 03:30:34.567890"
SET @date_english = FormatDate(@date, "l", "HH:MM tt", "en-us")
SET @date_spanish = FormatDate(@date, "l", "HH:MM tt", "es-mx")
@nmaratasdev
nmaratasdev / ampscript-format-functions-format-currency.amp
Created December 18, 2021 10:03
ampscript-format-functions-format-currency
<!-- Example Code -->
%%[
/**
* Format Currency Logic
* Formats a specified string as a currency value for a specified format and locale.
*/
VAR @price, @price_usa, @price_mexico, @price_france, @price_canada, @price_china
SET @price = "199.99"
SET @price_usa = FormatCurrency(@price, "en-us")
SET @price_mexico = FormatCurrency(@price, "es-mx")
@nmaratasdev
nmaratasdev / ampscript-format-functions-format.amp
Created December 18, 2021 10:03
ampscript-format-functions-format
<!-- Example Code -->
%%[
/**
* Format Logic
* This function formats a string into a specified format pattern and locale.
* Use this function for date and time formatting that requires a locale.
*/
VAR @date, @long_date_english, @long_date_spanish, @short_date_english, @short_date_spanish, @full_long_date_english, @full_long_date_spanish, @full_short_date_english, @full_short_date_spanish, @general_long_date_english, @general_long_date_spanish, @general_short_date_english, @general_short_date_spanish
SET @date = "2012-10-05 03:30:34.567890"
SET @long_date_english = Format(@date,"D", "Date", "en-us")