I'm trying to create an Outlook Userform, where via a drop down menu an operator can select an email template.
Using this example, this is the code for the Outlook form which works fine.
Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "Test"
.AddItem "Template 2"
.AddItem "Template 3"
.AddItem "Template 7"
.AddItem "Template 5"
.AddItem "Template 6"
End With
End Sub
Private Sub btnOK_Click()
lstNum = ComboBox1.ListIndex
Unload Me
End Sub
This is the code I've started to put together, to select the template. When I use the drop down menu to select the "Test Template" I receive a error here "Test.Select" highlighting an object is required.
Public lstNum As Long
Public Sub ChooseTemplate()
Dim oMail As Outlook.MailItem
Dim oContact As Outlook.ContactItem
Dim strTemplate As String
UserForm1.Show
Select Case lstNum
Case -1
' -1 is what you want to use if nothing is selected
strTemplate = "Test"
Case 0
strTemplate = "template-1"
Case 1
strTemplate = "template-2"
Case 2
strTemplate = "template-3"
Case 3
strTemplate = "template-4"
Case 4
strTemplate = "template-5"
End Select
Test.Select
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = "Test Facility"
.HTMLBody = "<BODY style=font-size:11pt;font-family:Calibri>Hi " You recently confirmed you require continued use of the test facility
"<p>Many thanks and kind regards</p></BODY>" & Signature
.Sensitivity = 2
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
wb.Close savechanges:=True
End If
Set oMail = Nothing
End Sub