Dim olApp As Outlook.Application
Dim MI As Outlook.MailItem
Dim sPath, sFileName, CurrentTime, Salutation As String
Dim sFileLocation As String
Dim wbAnswer, EmilAnswer As Integer
CurrentTime = Format(Now, "hh:mm:ss")
If CurrentTime > "05:00:00" And CurrentTime < "12:00:59" Then
Salutation = "Good morning "
ElseIf CurrentTime > "12:01:00" And CurrentTime < "16:59:59" Then
Salutation = "Good afternoon "
ElseIf CurrentTime > "17:00:00" And CurrentTime < "20:59:59" Then
Salutation = "Good evening "
Else
Salutation = "Dear "
End If
Set olApp = New Outlook.Application
Set MI = olApp.CreateItem(olMailItem)
DoCmd.SendObject
With MI
.To = EmailContact1
.CC = ""
.Subject = "Purchase Order Number: " & PONumber
.Body = Salutation & FirstName1 & "," & vbNewLine & vbNewLine
.Display
End With
Set MI = Nothing
Set olApp = Nothing