Solved

Outlook Macros (cc address)

Posted on 2015-02-04
6
171 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
Comment Utility
Macro can do it and rules are there for this purpose.
gowflow
0
 
LVL 76

Expert Comment

by:David Lee
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 76

Expert Comment

by:David Lee
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Set OWA language and time zone in Exchange for individuals, all users or per database.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

762 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

11 Experts available now in Live!

Get 1:1 Help Now