Solved

Auto BCC an outlook message and add to subject

Posted on 2013-06-25
7
713 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
  • 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
Set OWA language and time zone in Exchange for individuals, all users or per database.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now