Solved

Outlook Macros (cc address)

Posted on 2015-02-04
6
182 Views
Last Modified: 2015-03-23
Hi Guys,

What is the easiest way in MS Outlook to include a CC e-mail address automatically upon completing a "specific" TO address.

I guess we will have to write a macro for every combination between TO & CC addresses?
0
Comment
Question by:Rupert Eghardt
  • 3
  • 2
6 Comments
 
LVL 29

Expert Comment

by:gowflow
ID: 40590678
Macro can do it and rules are there for this purpose.
gowflow
0
 
LVL 76

Expert Comment

by:David Lee
ID: 40590810
Hi, Rupert.

If by "completing" you mean a solution that automatically inserts a CC as soon as you enter/select and address on the To line, then you'd want to find/build an add-in.  Macros aren't going to work and neither will rules.  A macro will work if you want to add the CC automatically when the user sends the message.  Rules won't work for that either since rules only fire when messages arrive and after they are sent.  

The code would look something like this.  This code would run each time you send something.  It first checks to see if the item is an email.  If it is, then it checks each of the message's addressees.  If the addressee is on the "To" line, then it checks their name against a list of names you've supplied (i.e. the names in the CASE statement).  If it finds a match, then it adds one or more addressees to the CC line.  When it's all done checking the addressees, it saves any changes to the message (i.e. the newly added CC addresses) and the message goes on its way.  You can add as many checks as you need.  The only requirement is that the name you check for must exactly match a name in the list of people on the To line.  

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim olkRec As Outlook.Recipient, strCC As String
    If Item.Class = olMail Then
        For Each olkRec In Item.Recipients
            If olkRec.Type = olTo Then
                Select Case olkRec.Name
                    Case "John"
                        strCC = strCC & "Bill@company.com;"
                    Case "Sally"
                        strCC = strCC & "Sam@company.com;Susie@company.com"
                End Select
            Next
        End If
        If Len(strCC) > 0 Then
            strCC = Left(strCC, Len(strCC) - 1)
            Item.CC = strCC
            Item.Save
        End If
    End If
End Sub

Open in new window

0
 

Author Comment

by:Rupert Eghardt
ID: 40607522
Thank you BlueDevilFan!

I am sure this will give us what we need.
The only problem that I see is that we have to modify the script with each "condition" being added.

I guess it will complicate things a lot to make it read from a table containing the condition / CC-Result fields?
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
LVL 76

Expert Comment

by:David Lee
ID: 40613910
No, it wouldn't complicate things a lot to read the condition info from a table.  Where do you envision the table being stored and in what format?
0
 

Author Comment

by:Rupert Eghardt
ID: 40616025
I followed up with the user and they are happy to insert a fixed list of conditions / CC-results in the script for now.
We don't have to configure a table at this time.

How do I link the script in Outlook to action every time a message is sent?
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 40616291
To use the script

1.  Start Outlook
2.  Press ALT+F11 to open the Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code from the code snippet box and paste it into the right-hand pane of Outlook’s VB Editor window
5.  Edit the code as needed
6.  Click the diskette icon on the toolbar to save the changes
7.  Close the VB Editor
8.  Click Tools > Trust Center
9.  Click Macro Security
10. Set Macro Security to “Warnings for all macros”
11. Click OK
12. Close Outlook
12. Start Outlook. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run. Say yes.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Sometimes Outlook might have problems sending a message. There may be various causes- corrupted PST, AV scanner etc. The message, instead of going to the Sent Items folder, sits in the Outbox indefinitely. To remove it you can use a free tool cal…
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
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…

862 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

30 Experts available now in Live!

Get 1:1 Help Now