"CC" field in mail has to be filled with userform's variable. It stays empty
Hello there,
I need a little help with my vba code.
The idea is to have a userform with a multiple choice (option buttons) and an "ok" button.
When the "ok" button is pressed, a new mail is created. The "CC" field has to be filled with an email adress depending on the choice made with the userform. (I replaced the mail adresses with [mail1] to [mail3].
I tried to make different changes without success. Whatever I do, the "CC" field stays blanck. All the rest works fine.
If anyone could have a look at my code bellow, and explain me what i'm doing wrong, it would really help me out.
Thanks in advance.
Best regards,
Rvr.
Code:
Public Sub CreateNewMessage()
Dim strCustomer As String
With CreateObject("Outlook.Application").CreateItem(0)
UserForm1.Show
.To = "[mail1]"
.CC = strCustomer
.Body = "xxx"
.Subject = ""yyy"
.Display
Unload UserForm1
End With
Set objMsg = Nothing
End Sub
---------------------------------------
Private Sub UserForm_Initialize()
optCustomer01.Value = True
End Sub
---------------------------------------
Private Sub cmdOK_Click()
If optCustomer01.Value = True Then
strCustomer = "[mail2]"
End If
If optCustomer02.Value = True Then
strCustomer = "[mail3]"
End If
UserForm1.Hide
End Sub