Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Language and In...Language and In...sending a localized email messagesending a localized email message
Previous
 
Next
New Post
11/22/2011 1:44 PM
 

Hi

I want to write some code to send a core email message using this resource:

EMAIL_PROFILE_UPDATED_BODY.Text

I've worked out how to send mail usng the DNN API.  However I don't know how to get a localised copy of a resource text.

Can anyone explain/demonstrate how?

thanks

Gus


"if the only tool you have is a hammer you tend to see every problem as a nail" http://www.carawaydesign.com
 
New Post
11/22/2011 6:05 PM
 

I've made some progress with this problem.

 string ResourceFile="/App_GlobalResources/GlobalResources.resx";
 string localizedText = Localization.GetString("EMAIL_PROFILE_UPDATED_BODY", ResourceFile);

Gets me the resource from the resx file.  I am assuming that the Localization object will take the localised version. If this is the case then I still have the problem of the tokens in the text which is:

Dear [User:DisplayName], Your profile on [Portal:PortalName] has been successfully updated. Sincerely, [Portal:PortalName]

Is there some way to autmatically replace the tokens in this text with the current users data?

 thanks

Gus


"if the only tool you have is a hammer you tend to see every problem as a nail" http://www.carawaydesign.com
 
New Post
11/22/2011 7:09 PM
 
you need to use core TokenReplace to replace the tokens with its actual values. Please check these articles: http://www.dotnetnuke.com/Resources/Blogs/EntryId/1547/4-6-0-A-Sneak-Peek-5-Token-Replace.aspx and http://www.dotnetnuke.com/Resources/Blogs/EntryId/1552/4-6-0-A-Sneak-Peek-6-Bulk-Mail-Admin-Newsletter.aspx

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
11/24/2011 8:30 AM
 

thanks Seb, that's a great help,

took me a while but i came up with this code which does the job. It looks up the email template for body and subject in the resources file, localises it, replaces the tokens and sends the user an email.

If I'm doing something wrong or undesirable please let me know.

thanks

gus

// get the localised email message and send the user an email
                string strResourceFile="/App_GlobalResources/GlobalResources.resx";
                string strlocalizedText = Localization.GetString("EMAIL_PROFILE_UPDATED_BODY", strResourceFile);
                string strlocalizedSubject = Localization.GetString("EMAIL_PROFILE_UPDATED_SUBJECT", strResourceFile);

                DotNetNuke.Services.Tokens.TokenReplace dnnTknRepl = new DotNetNuke.Services.Tokens.TokenReplace();
                dnnTknRepl.AccessingUser = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo();
                
                strlocalizedText = dnnTknRepl.ReplaceEnvironmentTokens(strlocalizedText);
                strlocalizedSubject = dnnTknRepl.ReplaceEnvironmentTokens(strlocalizedSubject);

               // lblError.Text = strlocalizedText;


                string strFrom = strPortalEmail; // portal email
                string strTo = ui.Email;         // user email
                string strSub = strlocalizedSubject; // email subject
                string strBody = strlocalizedText;   // email body
                // now send the email
                Services.Mail.Mail.SendEmail(strFrom, strTo, strSub, strBody);


"if the only tool you have is a hammer you tend to see every problem as a nail" http://www.carawaydesign.com
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Language and In...Language and In...sending a localized email messagesending a localized email message


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out