Using Gmail, can I create a script that allows me to key off of an address in the To/Cc field to add an address to the BCC field using some browser-side code?
Ex: Whenever an email with example@example.com is created in the TO/CC field (or created via a reply/reply-all etc) I want for the email address otherName@myCRM.com to be added to the BCC field.
I don't want this for a single address (or this would be much easier) I want to have a dictionary with many To/CC addresses that maps to many BCC addresses. I would also like to update the dictionary on a regular basis.
Here is a link to the API that I was planning on using to create this Google Apps Script: https://developers.google.com/apps-script/reference/gmail/
Is this possible? If so is there an example of doing it? I haven't been able to find one!
Because Google Apps Script runs server side, not client side, you can't do this in the way you have described.
While you can use Apps Script to access messages in the Drafts or Sent labels, it doesn't appear you can set the BCC value of those messages, only retrieve it.
One approach that might work is to poll the Draft or Sent messages folder on a fixed schedule, identify emails meeting your criteria, and then forward them to a given address (the one you wish to BCC). There are a number of challenges to this approach, such as determining how to avoid forwarding a given message multiple times, but it could be made to work.
See the docs on how to run your script on a schedule here:
https://developers.google.com/apps-script/guides/triggers/installable#time-driven_triggers
Edit, additional details in response to comment:
Setting up the triggers is very simple, I've used them many times in the past. You simply write a function that takes the actions you want, and once you have finished testing it manually, you can create the trigger via the "Resources" -> "Current Script's Triggers" menu options in the Script Editor.
You can't simply store processed id's in a variable, state is not shared between instances of the script. So you'll need to track them elsewhere, depending on volume you might want to look at the Properties Service, storing them in a spreadsheet, or my favorite would be to apply a label to processed emails and cross check the label in your script.
The label approach also lets you easily see which messages have been processed in the gmail interface.