i want to call the value of combobox and text box to another textbox i have form
ID: 3563215 • Letter: I
Question
i want to call the value of combobox and text box to another textbox
i have form with the one combo box and 2 text box, now i want to send that details in the mail and same as to be my subject line to mail
i am using below code.
Sub SendMessage(strMessage As String)
Dim oOutlookApp As Object
Dim oItem As Object
Dim olInsp As Object
Dim wdDoc As Object
Dim oRng As Object
On Error Resume Next
'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
'Outlook wasn't running, start it from code
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
End If
'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(0)
With oItem
.BodyFormat = 2
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
Set oRng = wdDoc.Range
oRng.collapse
oRng.Text = strMessage
.To = "*** Email address is removed for privacy ***"
.Subject =" --------------------------------------------------------------------------------"
.Display
'.Save
.Send
Unload Me
End With
'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
Set olInsp = Nothing
Set wdDoc = Nothing
lbl_Exit:
Exit Sub
End Sub
Explanation / Answer
Set oItem = oOutlookApp.CreateItem(0)
With oItem
.BodyFormat = 2
Set olInsp = .GetInspector
Set wdDoc = olInsp.WordEditor
Set oRng = wdDoc.Range
oRng.collapse
oRng.Text = strMessage
.To = "*** Email address is removed for privacy ***"
.Subject =TextBox1.Value & " " & TextBox2.Value & " " & ComboBox1.Value
.Body = TextBox1.Value & " " & TextBox2.Value & " " & ComboBox1.Value
.Display
'.Save
.Send
Unload Me
End With
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.