Solved

Outlook 2010 - How can I get prompted to populate the CC field when sending an email?

Posted on 2014-12-04
4
100 Views
Last Modified: 2014-12-15
When I click send mail, I would like a choice to cc a group.  If yes, add the addresses to the cc field, if choice is no, dont.  How would I do that?  I have limited experience with vba.

Thanks for any help that you can provide.
0
Comment
Question by:Michael Spellman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 26

Accepted Solution

by:
Nick67 earned 500 total points
ID: 40481294
This works, but the message box has a habit of getting behind Outlook or the mail message, causing grief
Substitute TheNameOfYourGroup with the appropriate thing
Code MUST go in ThisOutlookSession

Option Explicit
Public WithEvents m_Inspectors As Outlook.Inspectors
Public WithEvents m_Inspector As Outlook.Inspector
Public WithEvents myitem As Outlook.MailItem

Private Sub Application_Startup()
  Set m_Inspectors = Application.Inspectors
End Sub

Private Sub m_Inspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
  Set m_Inspector = Inspector
End Sub
'
Private Sub m_Inspector_Activate()
On Error GoTo exiterr
'is this item a mail item
If Not m_Inspector.CurrentItem.Class = OlObjectClass.olMail Then
    Set m_Inspector = Nothing
    Exit Sub
Else
    Set myitem = m_Inspector.CurrentItem
End If
Exit Sub
exiterr:
Set m_Inspector = Nothing
Set myitem = Nothing
End Sub
Private Sub myitem_Send(Cancel As Boolean)
Dim msg As Integer
    msg = MsgBox("Do you want to CC the group?", vbYesNo+ vbSystemModal, "CC?")
    If (msg = vbNo) Then ' no, then bail
        Set myitem = Nothing
        Exit Sub
    Else
        Dim ns As Outlook.NameSpace
        Dim Folder As Outlook.MAPIFolder
        Set ns = Outlook.GetNamespace("MAPI")
        Set Folder = ns.GetDefaultFolder(olFolderInbox)
        Dim objOutlookRecip As Outlook.Recipient
        Set objOutlookRecip = myitem.Recipients.Add("TheNameOfYourGroup")
        objOutlookRecip.Type = olCC
    ' Resolve each Recipient's name.
    For Each objOutlookRecip In myitem.Recipients
        objOutlookRecip.Resolve
    Next
    End If
End Sub

Open in new window

0
 

Author Comment

by:Michael Spellman
ID: 40482613
I placed the code in the ThisOutlookSession but I don't get the message box when I click on send.  Is there something else needed to trigger the event?  Thanks for the help.
0
 

Author Comment

by:Michael Spellman
ID: 40482628
I just checked the security settings and they were disabling the code.  It works fine.  Thanks very much!
0
 

Author Comment

by:Michael Spellman
ID: 40490890
Excellent!  I really appreciate it.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

695 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