0

I solicit you for the creation of an ampscript code to dynamically change the subject of an email in an automation.

I explain I have an email that sent every day but the object is back and hard blow is quite repetitive.

I would like to start with a different object by day of the week.

I think we have to adapt this function

%%[

VAR @Date, @Subject
SET @Date = FORMAT(DateAdd(Now(), "X","D"), "ddddd")

SET @Subject = ""

%%[IF @Date == "Monday" THEN]%%
    [@Subject=Objet A]
%%[ELSEIF IF @Date == "Tuesday" THEN]%%
    [@Subject=Objet B]

%%[ELSEIF IF @Date == "Wednesday" THEN]%%
    [@Subject=Objet c]

%%[ELSEIF IF @Date == "Thursday" THEN]%%
    [@Subject=Objet E]

%%[ELSEIF IF @Date == "Friday" THEN]%%
    [@Subject=Objet D]
%%[ELSEIF IF @Date == "Saturday" THEN]%%
    [@Subject=Objet F]
%%[ELSEIF IF @Date == "Sunday" THEN]%%
    [@Subject=Objet G]
%%[ELSE]%%
    [Objet base]
%%[ENDIF]%%

]%%

%%=v(@Subject)=%%

I'm a noob in ampscript so my syntax is probably false :)

Thanks in advance

2

You can try this piece of code:

%%[ VAR @Date, @Subject 
SET @Date = FORMAT(Now(), "ddddd") 
IF @Date == "Monday" THEN 
SET @Subject = "Monday subject line" 
ELSEIF @Date == "Tuesday" THEN 
SET @Subject = "Tuesday subject line" 
ELSEIF @Date == "Wednesday" THEN 
SET @Subject = "Wednesday subject line" 
ELSEIF @Date == "Thursday" THEN 
SET @Subject = "Thursday subject line" 
ELSEIF @Date == "Friday" THEN 
SET @Subject = "Friday subject line" 
ELSEIF @Date == "Saturday" THEN 
SET @Subject = "Saturday subject line" 
ELSEIF @Date == "Sunday" THEN 
SET @Subject = "Sunday subject line" 
ELSE 
SET @Subject = "Default subject line" ENDIF ]%% 

In your subject line, you can paste %%=v(@Subject)=%% This will populate the subject line as per the day of the week. I am not sure why you have DateAdd function in your code. If you need to adjust the dates, you can use it as per your requirement.

1

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.