• Quit Mail if it’s open.
• In ~/Library/Mail/V7/MailData, delete any file that begins with “Envelope Index,” such as Envelope Index or Envelope Index-shm.
• Your home Library folder is hidden by default. To display it, choose Finder > “Go to Folder” and then enter “~/Library”
• Open Mail.
• Mail creates new Envelope Index files. This process ...
You did not include the replaceName(mailBody, theName) handler, so I could not test the full script, however to fix the current error you need to modify the existing code.
repeat with i from 1 to number of items in theRecipients
set theContact to item i of theRecipients
set theName to name of theContact
set theEmail to email of ...
Open up a Finder app session
You will need access to your User library
Go to Folder Containers > com.apple.mail > Data > Library > Saved Application State
Go > Go To Folder and type in as shown above.
Move com.apple.mail.savedState to Trash
Move this folder to the trash
Next, in Finder app, press down the Option key and click on Go at the ...