Solved

Outlook Macros (cc address)

Posted on 2015-02-04
6
192 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

839 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