Hi,
I've created a userfrom to create an e-mail based on the values of text boxes, combo boxes and checkboxes.
Below is what I have written so far, and yes it is a mess. Just started with coding and learning but I couldn't find an answer on my "problem".
How can I simplify this?
Another thing: when I tick the checkbox "Partial" I want to have the text in the e-mail changed to "Please dispatch this order partially TODAY using ".
I've created a userfrom to create an e-mail based on the values of text boxes, combo boxes and checkboxes.
Below is what I have written so far, and yes it is a mess. Just started with coding and learning but I couldn't find an answer on my "problem".
How can I simplify this?
Another thing: when I tick the checkbox "Partial" I want to have the text in the e-mail changed to "Please dispatch this order partially TODAY using ".
VBA Code:
Private Sub Createbtn_Click()
Dim olApp As Outlook.Application
Dim olEmail As Outlook.MailItem
Set olApp = New Outlook.Application
Set olEmail = olApp.CreateItem(olMailItem)
With olEmail
.BodyFormat = olFormatHTML
.Display
.To = "test@test.nl"
.CC = "test@test.nl"
.Subject = "SO " & TumbaSO.Value & " (PO " & Koopbrief.Value & ")"
If cbETA.Value = True And cbForwarder.Value = True Then
.Body = "Dear Team," & vbNewLine & vbNewLine _
& "Please dispatch this order TODAY using " & Deliverymethod.Value & " " & Incoterm.Value & " to:" _
& vbNewLine & vbNewLine & Address.Value & vbNewLine _
& vbNewLine & "Forwarder: " & txtForwarder.Value & vbNewLine & "Account: " & txtFWDAccount.Value _
& vbNewLine & vbNewLine & "ETA: " & cbDay.Value & " " & cbMonth.Value & " " & cbYear.Value _
& vbNewLine & vbNewLine & "Kind regards," & vbNewLine & vbNewLine & cbRequestedby.Value _
& vbNewLine & vbNewLine & "Alfa Laval Nijmegen B.V."
ElseIf cbETA.Value = True Then
.Body = "Dear Team," & vbNewLine & vbNewLine _
& "Please dispatch this order TODAY using " & Deliverymethod.Value & " " & Incoterm.Value & " to:" _
& vbNewLine & vbNewLine & Address.Value & vbNewLine _
& vbNewLine & "ETA: " & cbDay.Value & " " & cbMonth.Value & " " & cbYear.Value _
& vbNewLine & vbNewLine & "Kind regards," & vbNewLine & vbNewLine & cbRequestedby.Value _
& vbNewLine & vbNewLine & "Alfa Laval Nijmegen B.V."
ElseIf cbForwarder.Value = True Then
.Body = "Dear Team," & vbNewLine & vbNewLine _
& "Please dispatch this order TODAY using " & Deliverymethod.Value & " " & Incoterm.Value & " to:" _
& vbNewLine & vbNewLine & Address.Value & vbNewLine _
& vbNewLine & "Forwarder: " & txtForwarder.Value & vbNewLine & "Account: " & txtFWDAccount.Value _
& vbNewLine & vbNewLine & "Kind regards," & vbNewLine & vbNewLine & cbRequestedby.Value _
& vbNewLine & vbNewLine & "Alfa Laval Nijmegen B.V."
Else
.Body = "Dear Team," & vbNewLine & vbNewLine _
& "Please dispatch this order TODAY using " & Deliverymethod.Value & " " & Incoterm.Value & " to:" _
& vbNewLine & vbNewLine & Address.Value & vbNewLine _
& vbNewLine & "Kind regards," & vbNewLine & vbNewLine & cbRequestedby.Value _
& vbNewLine & "Alfa Laval Nijmegen B.V."
End If
End With
End sub