I am trying to use the if then statement inside the .body of my email, but when ever I run it, it does nothing. Below where I noted the body of the email starts is where I am stuck.
Sub Email_From_Excel_Basic()
' This identifies what means what
Dim emailApplication As Object
Dim emailItem As Object
Dim mymsg As String
Dim cell As Range
Application.ScreenUpdating = False
Set emailApplication = CreateObject("Outlook.Application")
' Now we build the email.
On Error GoTo cleanup
For Each cell In Worksheets("owvr").Columns("S").Cells
Set emailItem = emailApplication.CreateItem(0)
If cell.Value Like "?*@?*.?*" And _
Cells(cell.Row, "T") = "Yes" Then
With emailItem
' This is who the email is being sent to
.To = Cells(cell.Row, "S").Value
.CC = Cells(cell.Row, "S").Value
' This is the subject of the email
.Subject = "Status update"' This is the body of the email based on cell references
mymsg = "Dear "& Cells(cell.Row, "A").Value & " team,"& vbNewLine & vbNewLine
Here
mymsg = mymsg & "Status: "& If Cell("D").Value = "1. New Order" Then
mymsg "Your order has been received and will processed."
ElseIf cell("D").Value= "2. Shipped" Then
mymsg = mymsg & "Status: Your order has been shipped"& vbNewLine
Else
End If
mymsg = mymsg & "Deposit invoice: "& Cells(cell.Row, "K").Value & vbNewLine
mymsg = mymsg & "Additional invoice: "& Cells(cell.Row, "M").Value & vbNewLine
.Body = mymsg
.Send
' This part brings the loop back up to the top, so this way it goes to the next email in the column
End With
On Error GoTo 0
Set emailItem = Nothing
End If
Next cell
cleanup:
Set emailApplication = Nothing
Set emailItem = Nothing
Set mymsg = Nothing
Application.ScreenUpdating = True
End Sub
Advice?