Hi everyone,
I'm new to Adobe Campaign Manager and I'm trying to use dynamic date in the email subject and email body. By dynamic date I meant is - days in month followed by month name - i.e. 30 September, 31 October and so on. Also, needs to consider February as a special case. Can anyone please tell me how I can do this in the email template? I can create HTML file and use javascript within the HTML but I'm not sure whether it is permissible to use such HTML as email delivery HTML in ACM. Also, what can be done for subject line with such dynamic date ?
Your help and guidance will really help me.
Solved! Go to Solution.
Views
Replies
Total Likes
Another implementation way
<%
function daysInMonth(today) {
return new Date(today.getFullYear(), today.getMonth(), 0).getDate();
}
var today = new Date();
%>
<%= daysInMonth(today) %> <%= formatDate (today, "%Bl") %>
Thank you for revert.
I used below mentioned approach but it didn't work out. Can you plz tell me why?
Last day of the month is: <% function daysInMonth(today) { return new Date(today.getFullYear(), today.getMonth(), 0).getDate(); } function month_fr(today){ var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }; return today.toLocaleDateString("fr-FR", { month: 'long'}); } var today = new Date(); %> <%= daysInMonth(today) %> <%= month_fr(today) %>, <%= formatDate (today, "%4Y") %>
And for your approach, can you please replace that in this code snippet so that I can try, if possible ?
Views
Replies
Total Likes
use this function instead of yours:
function month_fr(today){
var monthFr:["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre","Novembre","Décembre"];
var thisMonthFr = monthFr[today.getMonth()];
return thisMonthFr.toString();
}
Regarding the toLocalDateString it doesn't work because it isn't implemented natively in AC
My function works a bit the same as here:
Formatting | Adobe Campaign
Views
Replies
Total Likes
Thanks for providing the location for editing.
After using that snippet, email didn't come through from ACM to inbox.
Can you please let me know what might be the issue ?
Views
Replies
Total Likes
If you cannot provide the error message in the broadlog of your delivery, it will be hard to help you
Views
Replies
Total Likes
Hi Laurent,
After using that snippet, I analyzed the delivery and it didn't have any error. But when I sent that email as proof, it didn't come out. I don''t now where I should check logs in such case.
Also, similar thing happened with some other code in the past.
Views
Replies
Total Likes
Just open the delivery generated by your template and click on "delivery logs": the error message generated at MTA level will be shown
It seems that your onboarding on ACC has not been finished. You should ask for it or you'll be quickly limited as developper, architect or just simple user
Views
Replies
Total Likes
Hi Laurent,
Also, the number of days for October is coming as "30" in place of "31" with this code. Do you know the reason ?
Views
Replies
Total Likes
I'm not exactly sure what the issue is, as it's working for me.
If I had to troubleshoot, I'd simply the code until it starts working, then slowly re-introduce line by line until it stops. Then I'd know what line is causing the email to not deliver. e.g. Do a test only containing:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> </HEAD> <BODY> <DIV>This is test email and needs to be done by <% var d = new Date(); var dateString = "Testing" %>: <%=dateString%> Please see to it!</DIV></BODY></HTML>
If that works, change it to:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> </HEAD> <BODY> <DIV>This is test email and needs to be done by <% var d = new Date(); var m = d.getMonth(); var dateString = "Testing" %>: <%=dateString%> Please see to it!</DIV></BODY></HTML>
Once the delivery stops sending, you'll know what line is the problem.
Also, I'm presuming you're using AC Classic and not Standard, correct? What build?
Lastly, try to find the delivery that was generated under Campaign Management > Deliveries. (Or elsewhere) If it failed to deliver, you'll see it failed and can view the audit log for specifics about why it isn't sending.
I'm using AC Classic 7.0.19.1 build
I'm not sure why but I can send test emails. but not with any condition. I did check deliveries but couldn't find anything. I'm trying to send such email via "send a proof". so I think deliveries aren't there. While I try to send this email as a proof, there isn't any error while I analyze it.
Views
Replies
Total Likes
I just tried to use
<%=formatDate(getCurrentDate(),"%2D %Bl %4Y")%>
in the email body and that email didn't come through either. Can anyone please tell me what might be the issue ?
This snippet does work in the email subject.
Views
Replies
Total Likes
Does this work?
Hello <%=recipient.firstName%>
Also, if your emails aren't coming through, they are likely failing somewhere. You'll need to find the delivery and review the audit log. There is probably an error message to address.
Typically you'll find your outbound sends in Campaign Management > Deliveries.
Views
Replies
Total Likes
I kept subject as Test Email and used
Hello <%=recipient.firstName%>
inside email body. It worked.
Also, I used <%= formatDate(new Date(), "%Bl") %> in the subject and Hello <%=recipient.firstName%> in the email body. It worked.
But I'm not sure why formatDate isn't working email body.
Also, I'm sending this email as proof email so I'm not able to find anything in the delivery.
Views
Replies
Total Likes
Update:
Hello <%=recipient.firstName%> and month - <%= formatDate(new Date(), "%Bl") %>
This one also worked in the email body.
So I think there's issue with snippet for getting max number of days in a month.
Can you please help ?
Views
Replies
Total Likes
If you go to Help > About on your toolbar, what version of ACC are you running? (Client side and server side?)
Views
Replies
Total Likes
Hi Anthony,
I need one more help. Selected answer did work. If I want to have month name in French in subject as well as email body. Do you know how to do that?
Views
Replies
Total Likes
Thank you so much Anthony for your help, time and efforts.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies