Dynamic Date in Subject and email body | Community
Skip to main content
Level 2
September 23, 2021
Solved

Dynamic Date in Subject and email body

  • September 23, 2021
  • 2 replies
  • 10363 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by 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 replies

Level 6
September 23, 2021
vinay049Author
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")%>
vinay049Author
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 ?

vinay049Author
Level 2
October 4, 2021

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. 


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.