Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

sending mail using velocity template

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to use velocity template to send mail. I am getting the following error when i run the application.

ResourceManager : unable to find resource 'forgot-password.vm' in any resource loader.

I have forgot-password.vm file available in my classpath. I placed this file in the same directory where my controller lives.

my directory structure is : com/company/web/PasswordController.java

com/company/web/forgot-password.vm

i am pointing the .vm template like this from my passwordController class.


Can anyone help me how can solve the error.


 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if that argument expects a file path or a resource name, but either way, you need to fully qualify it.
 
Mukhi Vla
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got rid of that error by defining velocityEngine bean with 'resourceLoaderPath' property value.



But I am facing a different issue now.

I have french translated text in my mail body. I want to send mails in different languages. To support that i have a french translated text in my template.

English text: The account information you requested is below.

French Text:Les informations de compte que vous avez demandé est inférieur à

But in mail i have the above french text coming like this: Les informations de compte que vous avez demandé est inférieur Ã



how can i solve this issue?


Thanks
 
Marshal
Posts: 25826
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you have there is data, which was encoded using UTF-8, being displayed by something which incorrectly assumes it was encoded in some other charset (probably ISO-8859-1 or Windows-something). So you're going to have to fix some encoding declarations somewhere.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or multiple places, like the template file encoding itself, and the Velocity template merging, and possibly the email session you're using to send it.
 
Mukhi Vla
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Character encoding param is set to 'utf-8' already.



I did check that the problem is not with velocity template. I tried sending message by appending text to StringBuffer. With this change also it is not preseting the characters as it is. Still the message is printed like this "Les informations de compte que vous avez demandé est inférieur à "
 
Paul Clapham
Marshal
Posts: 25826
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand what you mean when you say the message is "printed". Perhaps the problem is with whatever is doing the printing?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And, as I said, the mail session itself needs to be sending in the proper encoding (or maybe just the content encoding header).
 
Mukhi Vla
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I don't understand what you mean when you say the message is "printed". Perhaps the problem is with whatever is doing the printing?



I mean mail message containing different characters than what I have.
 
Mukhi Vla
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i solved this by placing encoding parameter in mergeTemplateIntoString() method



It works
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic