function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Priyesh Misquith 12Priyesh Misquith 12 

send a email to group of user on their local language from batch apex.

Hello,

How to send a mail to the group of user of the different region in their local language. I want the header and full email body to be in the local language.The mail will be sent from the batch apex.

Thanks.
mukesh guptamukesh gupta
Hi Priyesh,

You need to use custom label for lenguage 

First, you'll need a template for each language that your org allows your users to use. Next, you'll need to use Global variables like $User to determine both their LocaleSidKey (controls how numbers, dates and currency are formatted) and their LanguageLocaleKey which is the actual language such as french, german, english, etc 

Your templates should be created with the appropriate settings to support the values of the above fields that your organization uses.

Translation workbench will only convert picklist values and field labels for you, not data values. Based on the above User fields, you'll need to set up which template to use for a User.

Or 

https://unofficialsf.com/send-html-email-1-32-now-supports-multi-language-for-lightning-email-templates/
Controller:

public class EmailSender {

public void sendMail() {

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

mail.setToAddresses(getEmailAddresses());

mail.setSubject('This is the subject');

mail.setPlainTextBody('This is the body.');

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

}

 

private List<String> getEmailAddresses() {

List<String> idList = new List<String>();

List<String> mailToAddresses = new List<String>();

Group g = [SELECT (select userOrGroupId from groupMembers) FROM group WHERE name = 'MyPubGroup'];

for (GroupMember gm : g.groupMembers) {

idList.add(gm.userOrGroupId);

}

User[] usr = [SELECT email FROM user WHERE id IN :idList];

for(User u : usr) {

mailToAddresses.add(u.email);

}

return mailToAddresses;

}

}

 

 In page:

<apex:commandbutton value="Send Mail" action="{!sendMail}"/>

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh