Auto BCC an outlook message and add to subject

I need to auto bcc every message I send through outlook (which is easy with VBA)BUT I also need to add text to the BCC subject though not the original one.

Is this possible?

I.E Original message gets sent as is with subject 'My Subject' ,  and BBC message has subject 'BBC - My Subject'
dbdpAsked:
Who is Participating?
 
omgangConnect With a Mentor IT ManagerCommented:
What version of Outlook?  OS?  Do you have macros enabled in Outlook?

I tested in Outlook 2007, win 7 Pro.  Each time I send an email the procedure is run and a second message is sent.  The second message is saved to my Sent Items folder.

You add the procedure to the ThisOutlookSession class module?

Try setting a break point at
On Error GoTo Err_Application_ItemSend
then send a test message.  The routine should fire and stop at the break point allowing you to step through the code line by line.

OM Gang
0
 
omgangIT ManagerCommented:
Not possible with a single message.  Consider that you're sending one message to a list of recipients.  Some of the recipients are listed in the To: field, some in the CC: field and some in the BCC: field.  It's still a single message being sent but it's distribution is being handled by the outbound mail server based upon the recipients in each of those fields.  What you're asking would require the mail server itself to modify the message before sending to BCC recipients.

You could create a routine in Outlook to automatically draft a copy of each message, modify the subject line accordingly and send it to a specified list of recipients but this will actually be a second message.  It will either end up in your Sent Items folder as a second message or not if you specifically choose not to save it in your Sent Items.  The original message will not be updated to show a BCC was added.

OM Gang
0
 
dbdpAuthor Commented:
Yes that would be fine too, I thought of it but not sure how to do it,

Any ideas?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
omgangIT ManagerCommented:
Well, I opened VBE in Outlook and I already had a procedure that did something very similiar....must be from a PAQ here on EE.  Anyway, I modified it a bit for your Q.  This does what you want.  Note that I added a For loop to enumerate the list of recipients and remove each one.  This is to prevent resending the copy of the message to the original recipients.  You'll need to add additional For..Next loops for CC recipients and BCC recipients; we need to remove all previous recipients so the second message is only sent to our designated BCC.  If desirable, you could add each existing recipient, from each For...Next loop, to string variables and then insert these string variables into the beginning of the message Body, e.g. "Original recipients included:  " & strRecips & vbCrLf & "CC:  " & strCC & vbCrLf & "BCC:  " & strBCC

OM Gang



Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
On Error GoTo Err_Application_ItemSend

    Dim NewItem As Outlook.MailItem
    Dim i As Integer
    Dim strBCCAddy As String, strNewSubject As String
   
        'address we want to send a copy of every message to
    strBCCAddy = "omgang@ee.com"
        'text we'll prepend to each subject line
    strNewSubject = "BCC -- "
   
        'use Outlook mailitem.copy method to grab a copy of the current mailitem object
    Set NewItem = Item.Copy
        'enumerate recipient list and remove each
    For i = 1 To NewItem.Recipients.Count
        NewItem.Recipients.Remove (i)
    Next i
        'now add our desired recipient
    NewItem.Recipients.Add (strBCCAddy)
        'modify the subject line
    NewItem.Subject = strNewSubject & NewItem.Subject
        'send the copy we just made
    NewItem.Send

Exit_Application_ItemSend:
        'destroy object variable
    Set NewItem = Nothing
    Exit Sub

Err_Application_ItemSend:
    MsgBox Err.Number & " (" & Err.Description & ") in procedure Application_ItemSend of VBA Document ThisOutlookSession"
    Resume Exit_Application_ItemSend

End Sub
0
 
omgangIT ManagerCommented:
Forgot to mention that you should add that procedure to the
ThisOutlookSession
class module

OM Gang
0
 
dbdpAuthor Commented:
I tried the code and it makes sense to me, but nothing seems to happen.

Any ideas as to why?
0
 
dbdpAuthor Commented:
Was the macros :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.