Solved

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

Posted on 2014-12-04
4
83 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
  • 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
Companies keep a much closer eye on costs today, so changing to new Technology – Microsoft Office 365 is the smartest move to take.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

747 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

13 Experts available now in Live!

Get 1:1 Help Now