AutoBCC in Outlook (Office 365), now with Claude Code

    This is a follow-up to my earlier posts on AutoBCC for Outlook 2007 & 2010 and 2016. Every time I reinstall Windows or rebuild my Outlook profile, I dig those posts up to set this thing up again. This time I tried something different. I had Claude Code do it for me.

    The mechanism underneath is the same as it has always been. Outlook still has no native AutoBCC, and the simplest way to add one is still a small VBA macro hooked into Application_ItemSend. What is new is who types it in. So this post has two parts. The manual way, updated for current Office 365 / Outlook classic. And the Claude Code way, with a prompt you can paste.


    Part 1 — The manual way (Office 365 / Outlook classic)

    The Developer tab is still hidden by default. The flow:

    1.) Enable the Developer tab. File → Options → Customize Ribbon → tick “Developer” on the right → OK.

    2.) Open the VBA editor. Press Alt+F11.

    3.) Find ThisOutlookSession. In the Project pane on the left: Project1 → Microsoft Outlook → double-click ThisOutlookSession.

    4.) Paste the macro. Replace the email addresses with your own.

    <pre class="wp-block-code language-vba"><code class="language-vba">
    Option Explicit

    ' Auto-BCC: routes a hidden copy of every outgoing message
    ' based on which account it is being sent from.
    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    On Error GoTo Cleanup

    If Item Is Nothing Then Exit Sub
    If Item.Class &lt;&gt; olMail Then Exit Sub

    Dim sender As String
    sender = ""
    If Not Item.SendUsingAccount Is Nothing Then
    sender = LCase(Trim(Item.SendUsingAccount.SmtpAddress))
    End If
    If sender = "" Then
    sender = LCase(Trim(Item.SentOnBehalfOfName))
    End If

    Dim bccAddr As String
    bccAddr = ""
    Select Case sender
    Case "primary@yourdomain.com", "personal@yourdomain.com"
    bccAddr = "archive-personal@gmail.com"
    Case "you@yourcompany.com"
    bccAddr = "archive-company@gmail.com"
    End Select

    If bccAddr = "" Then Exit Sub

    Dim r As Outlook.Recipient
    For Each r In Item.Recipients
    If r.Type = olBCC Then
    If LCase(Trim(r.Address)) = LCase(bccAddr) Then Exit Sub
    If LCase(Trim(r.Name)) = LCase(bccAddr) Then Exit Sub
    End If
    Next r

    Dim newR As Outlook.Recipient
    Set newR = Item.Recipients.Add(bccAddr)
    newR.Type = olBCC
    Item.Recipients.ResolveAll

    Cleanup:
    On Error Resume Next
    End Sub
    </code></pre>

    5.) Compile and save. Debug → Compile VBAProject. If there is no error you are good. Then Ctrl+S. The project saves as VbaProject.OTM.

    6.) Sign the project so it runs silently. Office 365 will not run unsigned VBA without nagging you on every restart. A self-signed certificate fixes that.

    • Run SELFCERT.EXE (it lives in C:\Program Files\Microsoft Office\root\Office16\). Give the cert a name like “My Outlook Macro”.
    • In the VBA editor: Tools → Digital Signature → Choose → pick your new cert → OK.
    • For the signature to actually verify, the cert needs to be in three Windows certificate stores: Personal, Trusted Root Certification Authorities, and Trusted Publishers. SELFCERT only puts it in Personal. To copy it into the other two, paste this into PowerShell:
    <pre class="wp-block-code language-powershell"><code class="language-powershell">
    $cert = Get-ChildItem Cert:\CurrentUser\My |
    Where-Object { $_.Subject -eq "CN=My Outlook Macro" } |
    Select-Object -First 1
    $cer = Join-Path $env:TEMP "MyOutlookMacro.cer"
    Export-Certificate -Cert $cert -FilePath $cer -Force | Out-Null
    Import-Certificate -FilePath $cer -CertStoreLocation Cert:\CurrentUser\Root
    Import-Certificate -FilePath $cer -CertStoreLocation Cert:\CurrentUser\TrustedPublisher
    </code></pre>

    7.) Set the macro security. File → Options → Trust Center → Trust Center Settings → Macro Settings → Notifications for digitally signed macros, all other macros disabled.

    8.) Restart Outlook. On the first launch you will get one prompt to trust the publisher. Accept it. After that the macro runs silently on every send.

    That’s it. Send a test mail from each account and confirm the BCC arrives.


    Part 2 — The Claude Code way

    If you have Claude Code installed with computer use turned on for Windows, you do not need to do any of the above by hand. You tell it the rules. It does the clicking.

    Open a fresh Claude Code session and paste a prompt like the one below. Replace the addresses with your own first.

    I want to set up AutoBCC in Outlook (classic) on Windows. I use multiple
    accounts and want every email I send to be silently BCC'd based on which
    account it goes from:

    - From primary@yourdomain.com -&gt; BCC archive-personal@gmail.com
    - From personal@yourdomain.com -&gt; BCC archive-personal@gmail.com
    - From you@yourcompany.com -&gt; BCC archive-company@gmail.com

    Please:
    1. Brainstorm and propose a plan first before doing anything.
    2. Use a VBA macro hooked into Application_ItemSend in ThisOutlookSession.
    3. Self-sign it with SELFCERT.EXE, and copy the certificate into Trusted
    Root and Trusted Publishers so the signature actually verifies.
    4. Configure Trust Center to "Notifications for digitally signed macros".
    5. Skip self-BCC duplicates if the BCC address is already on the email.
    6. Stop and ask me to confirm before any irreversible step (cert install,
    Trust Center change, Outlook restart).

    I'll restart Outlook myself when you say it's ready.

    Claude Code brainstorms, asks a couple of clarifying questions, opens Outlook, drops the macro into ThisOutlookSession, runs SELFCERT for you, installs the cert into the right stores using PowerShell, flips the Trust Center setting, and tells you when to restart. Mine took about ten minutes, most of which was me answering its questions.

    A few things to be aware of:

    • It will pause and ask you to confirm before installing the certificate and before flipping the Trust Center setting. That is the right behaviour. Don’t try to disable it.
    • The Windows certificate-selection dialog that pops up while signing is a system-owned window that Claude cannot click into. You have to click the cert and OK once yourself. Two seconds.
    • After the first Outlook restart you also have to manually trust the publisher on the security prompt. Same two seconds. From the next restart onward there are no prompts.

    Closing

    The macro itself is essentially the same one I have been carrying around since 2010, with a little hardening. What is new is that I no longer have to remember any of this. Next reinstall, I will probably just open Claude Code, paste the prompt, and go make coffee.

    Bingo.