?
Solved

Auto BCC an outlook message and add to subject

Posted on 2013-06-25
7
Medium Priority
?
733 Views
Last Modified: 2013-06-26
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'
0
Comment
Question by:dbdp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 28

Expert Comment

by:omgang
ID: 39274854
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
 

Author Comment

by:dbdp
ID: 39274978
Yes that would be fine too, I thought of it but not sure how to do it,

Any ideas?
0
 
LVL 28

Expert Comment

by:omgang
ID: 39275136
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Expert Comment

by:omgang
ID: 39275139
Forgot to mention that you should add that procedure to the
ThisOutlookSession
class module

OM Gang
0
 

Author Comment

by:dbdp
ID: 39277548
I tried the code and it makes sense to me, but nothing seems to happen.

Any ideas as to why?
0
 
LVL 28

Accepted Solution

by:
omgang earned 2000 total points
ID: 39278158
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
 

Author Closing Comment

by:dbdp
ID: 39278273
Was the macros :)
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question