+ Start a Discussion
rajesh k 10rajesh k 10 

How to write a code for forgot password?

Hi,
          I gave username and password .user forgot password on that time i gave forgotpassword link ,when user click fargot password ling that link pagerefers to Username page.Here  I gave username(this username is there in Customobject__ c object) textbox when i enter username click submit, automatically sent new password to my mail how?

please help me..........
Shabbir ShaikShabbir Shaik
Hi Rajesh,

Try like this,
use one method,  do query using username and fetch password and create single email functionality to send password to perticular email.

select id,Name,Password__c,Username__c from Customobject__c where Username__c =:username

If this is helps you, close the question by choosing a best answer.
rajesh k 10rajesh k 10
Hi,
            In my customobject__c record username is there, when i enter username click submit,automatically how to send that username related password to email using singleEmailMessaging.

please help me...
Bhawani SharmaBhawani Sharma
Query that password and use email.setPlainText or setHTMLBody method to send this to user.
rajesh k 10rajesh k 10
Hi,
              In google i saw like this code send emails

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] ToAddresses = new String[] {'mahesh060708@gmail.com'};
mail.setToAddresses(ToAddresses);
mail.setSubject('Apex Batch Job is done for insertion');
mail.setPlainTextBody('The batch Apex job processed ');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

Bhawani SharmaBhawani Sharma
Yes, correct. So you need to put the user's email address in the ToAddress and password in the setPlainTextBody method.
k sfdck sfdc
Hi,
 Like
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] ToAddresses = new String[] //Here how i add my email address;
mail.setToAddresses(ToAddresses);//Here how give password like {!customobject__C.password}
mail.setSubject('Apex Batch Job is done for insertion');
mail.setPlainTextBody('The batch Apex job processed ');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

Here where i will set my entered user name like(contact.username). and how to set plain text body.

I am a new in sending emails ,please help me.......
Bhawani SharmaBhawani Sharma
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
List<String> ToAddresses = new List<String>;
ToAddresses.add('someone@salesforce.com');

mail.setToAddresses(ToAddresses);

mail.setSubject('Password Reminder');
mail.setPlainTextBody('Password: ' + password__c);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });