Results 1 to 7 of 7

Thread: VBA code to add cc recipient based on outcome of option button selection on user form

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    VBA code to add cc recipient based on outcome of option button selection on user form

    Hi,

    I have the below code to prompt a user if an email about to be sent is to be tracked or not.

    if selected to be tracked the prefix *OPO * is added into the front end of the subject box, there is a little proportion of coding at the end of the sub to remove duplicate prefixes when forwarding etc.

    I'm completely stuck as to how to get the selection of option button one that drives the prefix to also automate the input of an email address into the CC field. If option button two is selected no email is to be entered.

    Current coding I've figured out is below and is held in ThisOutlookSession, any help appreciated.

    Thanks,


    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)


    Dim frm As UserForm1
    Dim chosenvalue As String
    Set frm = New UserForm1
    frm.Show vbModal
    Select Case True
    Case frm.OptionButton1.Value
    chosenvalue = "*OPO* "
    Case frm.OptionButton2.Value
    chosenvalue = ""
    Case Else
    MsgBox "You did not select a value, Cancelling send."
    Cancel = True
    Exit Sub
    End Select
    If TypeName(Item) = "MailItem" Then
    Item.Subject = chosenvalue & Item.Subject

    End If

    strSubject = Item.Subject
    strSubject = Replace(strSubject, "*OPO* ", "")
    strSubject = "*OPO* " & strSubject
    Item.Subject = strSubject

    Dim olApp As Outlook.Application
    Dim aItem As Object
    End Sub
    Last edited by anton1992; 06-18-2018 at 04:28 PM. Reason: Not clear about one point

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •