Dynamic Date in Subject and email body | Adobe Higher Education
Skip to main content
Level 2
September 23, 2021
Respondido

Dynamic Date in Subject and email body

  • September 23, 2021
  • 2 respostas
  • 10401 Visualizações

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.

Este tópico foi fechado para respostas.
Melhor resposta por LaurentLam

I'm not sure what's the issue.

 

I have removed the entire email.

 

And created simple HTML using the code given above. I didn't receive the test email. Is there any configuration related issue in MS Outlook for receiving email written with JS or configuration issue in ACM or anyother issue?

 

Because without that snippet, I can send and receive all the emails. Subject snippet did work but issue is with only this snippet.

 

Also, note that I can use dynamic first name in the body by Hi <%= recipient.firstName %> but I think only this date one isn't work. I'm not able to understand the issue.


Another implementation way

<%
function daysInMonth(today) {
     return new Date(today.getFullYear(), today.getMonth(), 0).getDate();
}
var today = new Date();
%>

<%= daysInMonth(today) %> <%= formatDate (today, "%Bl") %>

 

2 Respostas

Level 6
September 23, 2021
Level 2
September 23, 2021

Thank you for your reply. How to use format date for dynamic month in subject? Also, how to fetch number of days in a particular month and current month as dynamic one in the email body?

Level 6
September 24, 2021

Hi @vinay049 

You can try the following.

It works for me.

 

Subject:  welcome email - <%= formatDate(new Date(), "%Bl") %>

Body: <%= formatDate(new Date(), "%2D %Bl %4Y") %> 

 

Cheers,

Deb

Level 2
September 23, 2021

Hi vinay049,

 

You'll want to use formatDate and getCurrentDate.  Specs are at https://docs.adobe.com/content/help/en/campaign-classic/technicalresources/api/f-formatDate.html and https://docs.adobe.com/content/help/en/campaign-classic/technicalresources/api/f-getCurrentDate.html

 

The specific syntax would be:

<%=formatDate(getCurrentDate(),"%2D %Bl")%>
Level 2
September 23, 2021

Hi Anthony,

 

Tank you so much for your reply and suggestion.

 

I think I need to clarify the question. I want to do 2 things:

 

1. I want to display current month name in the email subject For example, welcome email - September

 

2. I want to display number of days in the current month, month name and year in the email body. For example, 30 September 2021.

 

This should be dynamic. I'm trying to figure out how to do this in ACM - Email Delivery - HTML file for email body and email subject within the Email Delivery option.

 

Can you able to help me out please ?

Level 2
October 4, 2021

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.


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.