aspose file tools*
The moose likes Spring and the fly likes Rich html email in spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Rich html email in spring" Watch "Rich html email in spring" New topic
Author

Rich html email in spring

vaijesh basavarajappa
Greenhorn

Joined: Feb 04, 2013
Posts: 5
Hi All,

Please help to generate html tabs in email template using springs.i want to include tabs in email.For Example: TAB1 TAB2. on click of TAB1 i want show some text "abcd".On click of TAB2 i want to show some tex t "efgh".

I used following code:


public class CustomerController{

@Autowired(required=true)
private JavaMailSender mailSender;

@Autowired(required=true)
private VelocityEngine velocityEngine;

@RequestMapping("/customer/add.htm")
public ModelAndView add(HttpServletRequest request,
HttpServletResponse response) throws Exception {
MimeMessage message=mailSender.createMimeMessage();
MimeMessageHelper helper=new MimeMessageHelper(message,true);
helper.setFrom("xxxx@gmail.com");
helper.setTo("xxxx@gmail.com");
helper.setSubject("Sending sample template");

Map<String, Object> model=new HashMap<String, Object>();
model.put("testing", "Ganesha is Lord");
String text = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "test3.vm", model);
FileSystemResource res = new FileSystemResource(new File("c:/header.jpg"));


helper.setText(text,true);
helper.addInline("identifier1234", res);

mailSender.send(message);
System.out.println("Ganesha sending mail"+text);

return new ModelAndView("CustomerPage", "msg","add() method");

}

}

Test3.vm file contains:

<html>
<head>
<script type="text/javascript">

function activateTab(pageId) {
var tabCtrl = document.getElementById('tabCtrl');
var pageToActivate = document.getElementById(pageId);
for (var i = 0; i < tabCtrl.childNodes.length; i++) {
var node = tabCtrl.childNodes[i];
if (node.nodeType == 1) { /* Element */
node.style.display = (node == pageToActivate) ? 'block' : 'none';
}
}
}

</script>
</head>
<body>
<img src='cid:identifier1234'>
<ul>
<li>
<a href="javascript:activateTab('page1')">${testing}</a>
</li>
<li>
<a href="javascript:activateTab('page2')">Tab 2</a>
</li>
...
</ul>
<div id="tabCtrl">
<div id="page1" style="display: block;">Page 1</div>
<div id="page2" style="display: none;">Page 2</div>
...
</div>
</body>
</html>

I could able to display the image.but tabs are not working.
Please help me.

Thanks in advance.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42913
    
  68
An email client is not a web browser. I'm not aware that there is one that will execute JavaScript (and I hope there isn't).
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Are you using the Spring Framework? I can't tell, what is "springs" I have not heard of "springs"

The Spring Framework has no plural.

Also, Please use the CODE tags, there is a Code button above to add them. When posting code so we can read it with nice clean indentations.

Thanks

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Rich html email in spring