• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sending mail using velocity template

 
Mukhi Vla
Ranch Hand
Posts: 53
  • 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.


 
David Newton
Author
Rancher
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: 53
  • 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
 
Paul Clapham
Sheriff
Pie
Posts: 20978
31
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
Rancher
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: 53
  • 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
Sheriff
Pie
Posts: 20978
31
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
Rancher
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: 53
  • 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: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i solved this by placing encoding parameter in mergeTemplateIntoString() method



It works
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic