Solved

Auto BCC an outlook message and add to subject

Posted on 2013-06-25
7
729 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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 500 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

691 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