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
Veerendar AellaVeerendar Aella 

i want to automate last login users greater than 30 days , an email as to be sent to managers with the same.

Hi All, 
When a last login user is greater than 30 days, then I want to send a automated email to the respective managers.
This can done by using
Process Builder
apex class
Please advice
Raj VakatiRaj Vakati
You have to apex scheduler jobs 

Use this sample code and implement email logic
global class LastLoginEmailJObs implements Schedulable {
   global void execute(SchedulableContext SC) {
    List<User> uds =[SELECT LastLoginDate FROM User]
	for(User u : uds){
	If( u.LastLoginDate<{
	// EMail Logic will go here 

Hi veerendar,

you can make use of workflow rule and time depen workflow rule to trigger an email alert to the manager.

Create a workflow rule on user object with some criteria like : If user is Active - True, then add a time dependent workflow action.

Please refer the below screenshot.

User-added image

Let me know if this helps.

Hi Raj,
Here is my requirement, could you please help me with this as Im new to development.

Schedulable Apex class to send an email to users whose last login is more than 30 days. what will be the email logic.

Raj VakatiRaj Vakati
You have to use Single Email Message or mass email message logics 
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); 
List <Contact> Con= [select id, name from Contact where name =:'xx']; 
mail.setSenderDisplayName('Salesforce Support'); 
EmailTemplate et=[Select id from EmailTemplate where Name=:'SFDC TEST']; 
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });