Hi all,
I am creating a user form within Excel file that is used to input data into the sheet, but also it is sending an email from outlook with specifics from that user form.
I have come to a standstill when trying to use option buttons from the user form.
I have tried to simply continue the text with:
if type1 = true then
"text text text"
else
"text2 text2 text2"
end if
However this clearly does not work. I am guessing i can do it if i use the cell from the sheet, but my goal is to get this done directly from the form. Below is the code i have so far:
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Dear colleagues " & vbNewLine & vbNewLine & firstname & " " & surname & " called in sick with their first day of absence being " & _
startday & "." & vbNewLine & "Reason for the absence is " & reason & "(" & code & ")"
'This is where is need to continue if option buttons
On Error Resume Next
With xOutMail
.To = "filarap@yahoo.com"
.CC = ""
.BCC = ""
.Subject = "text of subject " & firstname & " " & surname
.Body = xMailBody
.send 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
Regards
Filarap
I am creating a user form within Excel file that is used to input data into the sheet, but also it is sending an email from outlook with specifics from that user form.
I have come to a standstill when trying to use option buttons from the user form.
I have tried to simply continue the text with:
if type1 = true then
"text text text"
else
"text2 text2 text2"
end if
However this clearly does not work. I am guessing i can do it if i use the cell from the sheet, but my goal is to get this done directly from the form. Below is the code i have so far:
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Dear colleagues " & vbNewLine & vbNewLine & firstname & " " & surname & " called in sick with their first day of absence being " & _
startday & "." & vbNewLine & "Reason for the absence is " & reason & "(" & code & ")"
'This is where is need to continue if option buttons
On Error Resume Next
With xOutMail
.To = "filarap@yahoo.com"
.CC = ""
.BCC = ""
.Subject = "text of subject " & firstname & " " & surname
.Body = xMailBody
.send 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
Regards
Filarap