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

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});
            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()));


Adding this doesnt seem to work.

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