donny1shot
New Member
- Joined
- Mar 8, 2018
- Messages
- 18
Hi all,
I am trying to send multiple sections of my userform as email the current code I am using (below) works but if I try and add more code in to add say SYSTEM 2 DETAILS it would no longer show SYSTEM 1 DETAILS on the email and just the latter.
Private Sub CommandButton1_Click()
Dim sMessage As String, sHeading As String
' Check for valid data on the user form
'...
'Compile the message body:
sMessage = "SYSTEM 1 DETAILS:" & vbCrLf
sMessage = sMessage & "System: " & ComboBox1 & vbCrLf
sMessage = sMessage & "Height: " & ComboBox4 & vbCrLf
sMessage = sMessage & "Posts: " & TextBox1 & vbCrLf
sMessage = sMessage & "Panels: " & TextBox2 & vbCrLf
sMessage = "SYSTEM 2 DETAILS:" & vbCrLf
sMessage = sMessage & "System: " & ComboBox8 & vbCrLf
sMessage = sMessage & "Height: " & ComboBox9 & vbCrLf
sMessage = sMessage & "Posts: " & TextBox13 & vbCrLf
sMessage = sMessage & "Panels: " & TextBox15 & vbCrLf
sHeading = "NSD REQUEST " & Date
Mail_workbook_Outlook sHeading, sMessage
End Sub
'--------------------------------------------
Sub Mail_workbook_Outlook(sSubject As String, sBody As String)
'--------------------------------------------
Dim OutApp As Object
Dim OutMail As Object
Const sTo As String = "my email"
Const sCC As String = ""
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = sTo
.CC = sCC
.BCC = ""
.Subject = sSubject
.body = sBody
'.Attachments.Add
.Importance = 2
.Send
End With
'clean up
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
I am trying to send multiple sections of my userform as email the current code I am using (below) works but if I try and add more code in to add say SYSTEM 2 DETAILS it would no longer show SYSTEM 1 DETAILS on the email and just the latter.
Private Sub CommandButton1_Click()
Dim sMessage As String, sHeading As String
' Check for valid data on the user form
'...
'Compile the message body:
sMessage = "SYSTEM 1 DETAILS:" & vbCrLf
sMessage = sMessage & "System: " & ComboBox1 & vbCrLf
sMessage = sMessage & "Height: " & ComboBox4 & vbCrLf
sMessage = sMessage & "Posts: " & TextBox1 & vbCrLf
sMessage = sMessage & "Panels: " & TextBox2 & vbCrLf
sMessage = "SYSTEM 2 DETAILS:" & vbCrLf
sMessage = sMessage & "System: " & ComboBox8 & vbCrLf
sMessage = sMessage & "Height: " & ComboBox9 & vbCrLf
sMessage = sMessage & "Posts: " & TextBox13 & vbCrLf
sMessage = sMessage & "Panels: " & TextBox15 & vbCrLf
sHeading = "NSD REQUEST " & Date
Mail_workbook_Outlook sHeading, sMessage
End Sub
'--------------------------------------------
Sub Mail_workbook_Outlook(sSubject As String, sBody As String)
'--------------------------------------------
Dim OutApp As Object
Dim OutMail As Object
Const sTo As String = "my email"
Const sCC As String = ""
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = sTo
.CC = sCC
.BCC = ""
.Subject = sSubject
.body = sBody
'.Attachments.Add
.Importance = 2
.Send
End With
'clean up
Set OutMail = Nothing
Set OutApp = Nothing
End Sub