Solved

Outlook Macros (cc address)

Posted on 2015-02-04
6
187 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
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 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Find out what you should include to make the best professional email signature for your organization.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
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…

831 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