+ Start a Discussion
uHaveOptionsuHaveOptions 

Date Stamp on Public Void Method

I have this button that will acces a public void send.  It will send an email which is great.  however, I would it to date stamp letter_date__c field in the account object everytime I send an email or press the send button.  It should constantly overwrite the field. Any ideas?
 
public void send() {
        try {
            DM_Public_Page_URL__c siteCS = DM_Public_Page_URL__c.getValues('Default');
            String siteURL = siteCS.Site_URL__c;
 
            List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
            EmailTemplate emailT = [select Subject, HtmlValue from EmailTemplate whereDeveloperName = 'Millenial_Form' limit 1];
             
            for(Contact primaryContact : primaryContactList) {
                String body = emailT.HtmlValue.replace('{account_form}', siteURL + '/apex/AgeMillenial?id=' + accountId);
                body = body.replace('{primary_contact_name}', primaryContact.FirstName);
                body = body.replace('{account_name}', accountName);
                 
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                mail.setToAddresses(new String[]{primaryContact.Email});
                mail.setSubject(emailT.Subject);
                mail.setHtmlBody(body);
                mails.add(mail);
            }
             
            List<Messaging.SendEmailResult> results = Messaging.sendEmail(mails);
            if(results[0].isSuccess()) {
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Mail Sent'));
            } else {
                System.debug('------------------- errors: ' + results[0].getErrors());
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Mail Issue.  There's no email: ' + results[0].getErrors()));
            }
        } catch(Exception e) {
            System.debug('------------------- ERROR: ' + e.getStackTraceString());
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Mail Issue.  There's no email: ' + e.getStackTraceString()));
             
        }
 }


Thanks
uHaveOptionsuHaveOptions

Adding this doesnt seem to work.

for(account acc : accountID) {
                acc.letter_date__c = datetime.now(); 
            }