Setting the BCC Field in the active window of Mail

Hi, I'm trying to build a workflow in which I can set the BCC field of the active Mail window to a specific address.

I'd like to select the mail-window, trigger the macro with a keyboard shortcut and have the BCC field populated with the address value stored in the macro.

my problem is that I can not find a way to select reliably the BCC field of the active mail window.

any ideas ??

cheers
Jörg-Mark

Don't bother trying to imitate a user in the UI, simply set the BCC using AppleScript:

In fact, you might find it easier to do the message creation in the same script -- it's safer get the message ID on creation then refer to it with that than to rely on it being the frontmost message (although, in your described workflow, there shouldn't be a problem). Perhaps post the rest of your macro so we can see what else can be moved/optimised?

Hi Nige_S thanks for your fast reply :slight_smile:

I tried the script but it does nothing visible. My guess is that as you already mentioned there might be a problem with the ID of the window.

I can not create the mail in the same script because it is initialised by an other Programm and I need to add the bcc to the existing mail.

is there an other way to address the active mail window ? or to first find out if this is the problem ??

cheers
Jörg-Mark

Silly question, but when you make a new email or reply in Mail -- is the BCC field visible? IIRC, BCC isn't enabled by default...

If you initialise the email with the other program and, instead of running your KM script, switch to Mail -- is the new email open? Is it the frontmost window in Mail? Is it even open, or is it just a new outgoing Mail in Drafts?

What is the other program? Is there the chance to add the BCC in that (I'm guessing not, or you wouldn't be asking!) or somehow get information from it about the email it has just created (eg write out the message ID to a temp file so your KM macro can refer to it)?

Failing all the above -- if there's consistent behaviour, eg the new email is always the second window back and always opens with the cursor in the content area, you might be able to do this by sending keyboard commands from KM, like "Shift-Tab four times, then paste the variable, then Tab four times".

Hi,

the BCC field is visible and I selected the mail window so it should be the "first"...

When sending an invoice to a client the recipient is filled in by billings pro and the invoice is attached but unfortunately it is not possible to add a bcc address.

my goal is to send automatically a copy of the invoice to my accountant without bothering the clients with this cryptic mail address.

I can only apologise. What was working for me yesterday in testing -- isn't working today!

Working with outgoing mails in Mail (or Outlook) is a pain when you don't create the email as part of the script -- it seems next to impossible to reliably reference them correctly. So, back to GUI scripting...

I'm afraid that getting a trial of Billings Pro is next to impossible, and I've given up :frowning: But if its email creation behaves in a regular, dependable, fashion you should be able to script GUI actions to do what you want. After creating the email in Billings, when you switch to Mail which (if any) of the email "parts" is the cursor in?