Hi, i am having problem with this code below:
Sub mail()
Dim OutApp As Object
Dim OutMail As Object, Recip
Dim strto, strsub, strbody As String
Dim myRange, cell As Range
Dim row As Integer
Dim ws As Worksheet
ThisWorkbook.Save
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set myRange = Range("A2:A9")
strto = "[email protected];[email protected]"
strsub = "Upcoming expiry and re-orders"
row = 1
For Each cell In myRange
row = row + 1
If Cells(row, "G").Value = Cells(row, "I").Value And Cells(row, "A").Value <> "" And Cells(row, "J").Value = "" Then
Cells(row, "J").Value = "Y"
strbody = "Attention to the following item(s) reaching expiry soon:" & vbCrLf & vbCrLf
strbody = strbody & Cells(row, "B").Value & " " & "Lot No." & " " & Cells(row, "D").Value & " " & Cells(row, "G").Value & " days left before expiry" & vbCrLf
End If
Next cell
row = 1
For Each cell In myRange
row = row + 1
If Cells(row, "F").Value = Cells(row, "H").Value And Cells(row, "A").Value <> "" And Cells(row, "K").Value = "" Then
Cells(row, "K").Value = "Y"
strbody = strbody & vbCrLf & "Attention to the following item(s) reaching reorder point:" & vbCrLf & vbCrLf
strbody = strbody & Cells(row, "B").Value & " " & "Lot No." & " " & Cells(row, "D").Value & " " & Cells(row, "F").Value & " units left" & vbCrLf
End If
Next cell
If strbody = "" Then
Exit Sub
End If
With OutMail
.To = strto
.Subject = strsub
.body = strbody
.send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
it works fine on my other computer running windows 10 enterprise, so i suspect its the email application that differs (outlook 2016 on my enterprise while it seems like an app in the windows 10 pro).
Can someone help me with the code please?
Bookmarks