You need to sign in to do that
Don't have an account?
Veerendar Aella
I want to send warning email alerts to users who's last login greater than 90 days.
I want to send warning email alerts to users who's last login greater than 90 days. Please help.
Refer this link
https://salesforce.stackexchange.com/questions/152882/deactivate-user-whose-last-login-is-more-than-30-days
https://developer.salesforce.com/forums/?id=9060G000000UasZQAS
All Answers
Refer this link
https://salesforce.stackexchange.com/questions/152882/deactivate-user-whose-last-login-is-more-than-30-days
https://developer.salesforce.com/forums/?id=9060G000000UasZQAS
You can try something like this Hope this helps!
I need a test class for the below apex class
global class EmailToUser implements Database.Batchable<sObject>
{
List<String> UserEmailList = new List<String>();
global Database.QueryLocator Start(Database.BatchableContext BC)
{String query ='';
User[] selectedUsers = [SELECT Id, email FROM User WHERE IsActive = TRUE AND Id NOT IN (Select UserId from LoginHistory WHERE LoginTime = LAST_N_DAYS:1)];
//User[] selectedUsers = [SELECT Id, email FROM User WHERE IsActive = TRUE AND Id NOT IN (SELECT UserId FROM LoginHistory WHERE LoginTime = LAST_N_DAYS:30)];
system.debug('users' +selectedUsers);
return Database.getQuerylocator(query);
}
global void execute(Database.BatchableContext BC, List<User> scope)
{
for(User userobj:scope){
userEmailList.add(userobj.email);
}
}
global void finish(Database.BatchableContext BC)
{
List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(userEmailList);
Mail.setSubject('Updating Subject');
mail.setSaveASActivity(False);
mail.setPlainTextBody('Sample Body');
Messaging.sendEmail(new messaging.singleEmailMessage[] {Mail});
}
}
try this code