The following steps need to follow for EMAIL implementation.
Need to configure the following values in any component where email logic is written.
1) configuration at component (properties file)level
templateEmailSender=/atg/userprofiling/email/TemplateEmailSender
contentProcessor=/atg/userprofiling/email/HtmlContentProcessor
fillFromTemplate=true
2)Code to sent email as part of java code
TemplateEmailInfoImpl templateEmailInfo = null;
templateEmailInfo = new TemplateEmailInfoImpl();
param.put("emailContent",htmlMessage);
templateEmailInfo.setContentProcessor(getContentProcessor());
templateEmailInfo.setFillFromTemplate(isFillFromTemplate());
templateEmailInfo.setTemplateParameters(param);
templateEmailInfo.setTemplateURL("email template jsp path");
templateEmailInfo.setMessageFrom(senderEmail);
String recipientArray[] = {receipeingEmailId};
getTemplateEmailSender()).sendEmailMessage(templateEmailInfo, recipientArray);
3) The JSP or email template should have this code as follows to display the content from param.
<dsp:valueof param="emailContent" valueishtml="true"/>.
4)SMTPEmail component
SMTPEmail.properties
$class=atg.service.email.SMTPEmailSender
# Remote smtp host to actually send the email.email handler server ip address
emailHandlerHostName=xx.yxx.ww
emailHandlerPort=25
defaultFrom=noreply@liverpool.com
waitForConnectionMillis=200004)
5)Need to update the \atg\dynamo\Configuration.properties
siteHttpServerPort=local server port
siteHttpServerName=local server address
updating dynamic value as part of the HTML content using backend (used L--l )
If we want to update the dynamic values as part of the HTML content, we have to use the following code snippet.If we want to sent different values for different users,then only we have to use this.
The classes Document,Jsoup,Element are available in the jar. jsoup-1.11.2.jar.
We have to add the jar as part lib folder of the particular module and update in MANIFEST.MF file as follows.
ATG-Class-Path: lib/jsoup-1.11.2.jar
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
Document templateDoc = null;
try{
//the incoming HTML conent which come as part of JSON request.
String htmlContent = pHtmlContent;
templateDoc = Jsoup.parse();
Element xxxTag = templateDoc.getElementById("Id in html document");
if(xxxTag != null){
xxxTag.html("some application dynamic value to do added in the document");
}
}catch(MalformedURLException e){
}
Need to configure the following values in any component where email logic is written.
1) configuration at component (properties file)level
templateEmailSender=/atg/userprofiling/email/TemplateEmailSender
contentProcessor=/atg/userprofiling/email/HtmlContentProcessor
fillFromTemplate=true
2)Code to sent email as part of java code
TemplateEmailInfoImpl templateEmailInfo = null;
templateEmailInfo = new TemplateEmailInfoImpl();
param.put("emailContent",htmlMessage);
templateEmailInfo.setContentProcessor(getContentProcessor());
templateEmailInfo.setFillFromTemplate(isFillFromTemplate());
templateEmailInfo.setTemplateParameters(param);
templateEmailInfo.setTemplateURL("email template jsp path");
templateEmailInfo.setMessageFrom(senderEmail);
String recipientArray[] = {receipeingEmailId};
getTemplateEmailSender()).sendEmailMessage(templateEmailInfo, recipientArray);
3) The JSP or email template should have this code as follows to display the content from param.
<dsp:valueof param="emailContent" valueishtml="true"/>.
4)SMTPEmail component
SMTPEmail.properties
$class=atg.service.email.SMTPEmailSender
# Remote smtp host to actually send the email.email handler server ip address
emailHandlerHostName=xx.yxx.ww
emailHandlerPort=25
defaultFrom=noreply@liverpool.com
waitForConnectionMillis=200004)
5)Need to update the \atg\dynamo\Configuration.properties
siteHttpServerPort=local server port
siteHttpServerName=local server address
updating dynamic value as part of the HTML content using backend (used L--l )
If we want to update the dynamic values as part of the HTML content, we have to use the following code snippet.If we want to sent different values for different users,then only we have to use this.
The classes Document,Jsoup,Element are available in the jar. jsoup-1.11.2.jar.
We have to add the jar as part lib folder of the particular module and update in MANIFEST.MF file as follows.
ATG-Class-Path: lib/jsoup-1.11.2.jar
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
Document templateDoc = null;
try{
//the incoming HTML conent which come as part of JSON request.
String htmlContent = pHtmlContent;
templateDoc = Jsoup.parse();
Element xxxTag = templateDoc.getElementById("Id in html document");
if(xxxTag != null){
xxxTag.html("some application dynamic value to do added in the document");
}
}catch(MalformedURLException e){
}
No comments:
Post a Comment