none
VBScript - Managing recipients from GetSelectNamesDialog RRS feed

  • Question

  • I am very new to custom Outlook forms and VBScript. My form has 4 buttons to select 4 people from the GAL who serve in different roles. I would like to copy these selections to the "To" field in the Message tab so that the form is sent to all of them.

    So far I have been able to populate 4 custom fields with the following function, then use the Item_PropertyChange method to populate the To field with a concatenation of these fields separated by semi-colons.

        Function GetOneNameViaCDO()
            ' start CDO session
            Set objSession = CreateObject("Outlook.Application")
            objSession.GetNamespace("MAPI").Logon , , False, False

            set oDialog = Application.Session.GetSelectNamesDialog

            With oDialog
                .AllowMultipleSelection = false
                 .SetDefaultDisplayMode 5
                 .Caption = "Select Project Manager"
                .ToLabel = "Project Manager:"
                .Display

                If .Recipients.Count > 0 Then
                    Set GetOneNameViaCDO= .Recipients.Item(1)
                End If
            End With
        End Function

    Unfortunately, this just puts the "text" name of the recipients in the To field that have to be resolved before the message can be sent. (I'm getting strange errors when that happens, but I'm hoping they will go away when I figure out how to do this correctly.)

    So my question is: Is there a way to save the actual "recipient" objects in custom fields, then add them to the To field before sending? If not, how would I save the the email addresses from the recipients in custom fields and copy those to the To field so that they are resolved automatically before sending?

    Thanks!

    Tuesday, March 25, 2014 5:32 PM

Answers