Incorporate selection from combobox into body of email

kballan2023

New Member
Outlook version
Outlook 365 64 bit
Email Account
Exchange Server
I am trying to incorporate a selection from a userform combobox into the body of an email that is being forwarded. I am trying to write the selection to a defined variable strDispute and then concatenate it into standard text in the htmlbody. Everything works ok but for the fact that no matter which item I select from the combobox, the only item that gets concatenated into the body of my forwarded email is Choice 1

I believe I have a fairly standard configuration for my UserForm, the code of which is provided below

Option Explicit

Private Sub CommandButton1_Click()
Dim lstNo As Integer
lstNo = ComboBox1.ListIndex
Unload Me

End Sub


Private Sub UserForm_Activate()

With ComboBox1
.AddItem "Choice 1"
.AddItem "Choice 2"
.AddItem "Choice 3"
End With

End Sub

My macro code is provided below

Sub ForwardEmail()

Dim myinspector As Outlook.Inspector
Dim myItem As Outlook.MailItem
Dim strDispute As String


Set myinspector = Application.ActiveInspector
Set myItem = myinspector.CurrentItem.Forward

UserForm1.Show

Select Case lstNo
Case -1
' -1 is what you want to use if nothing is selected
strDispute = ""
Case 0
strDispute = "Choice 1"
Case 1
strDispute = "Choice 2"
Case 2
strDispute = "Choice 3"

End Select


myItem.Display

With myItem

.Recipients.Add "email@mail.com"
.Subject = "Subject"
.HTMLBody = "<HTML><BODY>Hi Fred,<br><br> Please see below disputed MVF lead. Issue was " & strDispute & ". </BODY></HTML>" & myItem.HTMLBody

End With

Set myItem = Nothing

End Sub

I am very new to VBA coding so have probably broken countless rules, but hoping someone might be able to advise what I need to do to achieve the intended functionality.
 
Similar threads
Thread starter Title Forum Replies Date
S Need code to allow defined starting folder and selection from there to drill down Outlook VBA and Custom Forms 10
T Outlook Template - textbox visible based on combobox selection Using Outlook 1
A Run-time error '430' on certain emails when trying to set "Outlook.mailitem" as "ActiveExplorer.Selection.Item" Outlook VBA and Custom Forms 2
Y Outlook Task View - Table Format - Customize Reminder Time to Drop-Down Selection Using Outlook 2
O Force account selection for sending reply emails Using Outlook 1
L Navigation Pane selection with shortcuts Using Outlook 2
C Force account selection - no reg path nor can create one Using Outlook 9
W Outlook: Uniquely identifying attachments in selection Using Outlook 0
D Selection of Send-From Account with Template VBA Shortcut Using Outlook 0
P Field option selection resulting into multiple questions BCM (Business Contact Manager) 0
K Default Account and Signature Selection Using Outlook 5
Y Changing colour of selection bar in Outlook (too light, needs to be grey) Using Outlook 4
P Outlook contact form no longer requiring Category selection to add new Using Outlook 1
N Changing the 'Mark item as read when selection changes' at runtime Outlook VBA and Custom Forms 1
P How to improve the email item selection event performance? Outlook VBA and Custom Forms 1
K How do I eliminate the "Enable Macro" selection? Outlook VBA and Custom Forms 16
C Eliminate need for "Enable Macro" selection Outlook VBA and Custom Forms 7
X Re: how to access current text selection Outlook VBA and Custom Forms 1
S Automating the selection of email accounts upon adding email addre Outlook VBA and Custom Forms 1
Z Add ComboBox Value to Body of Email Outlook VBA and Custom Forms 1
C Trying to populate an appointment ComboBox from Excel Outlook VBA and Custom Forms 2
N Select Appointment subject line from combobox or list Outlook VBA and Custom Forms 1
C Autofill subject line in appointment from options selected in combobox Using Outlook 6
B Contact Page 2 Combobox via Registry Outlook VBA and Custom Forms 6
N Combobox in outlook add ons toolbar not firing event on main window resized Using Outlook 3
S Dynamically add recipients using combobox and checkbox????? Using Outlook 2
J userform combobox Outlook VBA and Custom Forms 1
R combobox list in userform Outlook VBA and Custom Forms 1
K Alignment in Combobox Outlook VBA and Custom Forms 1
P Setting combobox properties from Outlook 2007 Add-in Outlook VBA and Custom Forms 9
K Adding watermark to Combobox in Outlook. Outlook VBA and Custom Forms 1
C ComboBox data Outlook VBA and Custom Forms 2
D ComboBox with Multi columns Outlook VBA and Custom Forms 4
S ComboBox (using Commas) Outlook VBA and Custom Forms 4
E Where is the best place to store values for combobox entries Outlook VBA and Custom Forms 5
E Where is the best place to store values for combobox entries Outlook VBA and Custom Forms 5

Similar threads

Back
Top