'Transferring variable from userform in the itemsend routine in outlook

currently, I have a routine in outlook that is run when I send and email.

The object of the code is to automatically CC a person in organization A whenever I email person B. That being said, I have a userform with radio buttons that have the 4 people in organization A so I can select them to be CCd when I send the email.

When I click send I can get the userform to open and assign the correct value to the variable based on what button I click on the userform.

However, I cannot get this value to transfer back to the itemsend routine once I click OK the userform subroutine. Below is the code:

From the userform

Private Sub CommandButton1_Click()

            Dim strBcc As String
            If option1.Value = True Then
            strBcc = "[email protected]"
            End If
End Sub
Set frm = New userfrm
            frm.show

From the item send:

Set frm = New userfrm
            frm.show

Once is tell the itemsend to show my userform, how do I transfer that input back to the itemsend routine?



Solution 1:[1]

In CommandButton1_Click hide the form. No other code.

In ItemSend

If frm.option1.Value = True Then
    strBcc = "[email protected]"

Solution 2:[2]

The property will be set on the item. You should be able to access it using MailItem.PropertyAccessor.GetProperty. To see the actual DASL property name, look at the item in the Sent Items folder with OutlookSpy (I am its author) - click IMessage button, select the property in question, look at the DASL edit box.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 niton
Solution 2