Option Compare Database
Public Sub Command28_Click()
Call SendEmail
End Sub
Sub SendEmail()
Dim MyTime As Date
Dim MyDate As String
Dim Greetings As String
MyTime = Format(Time, "hh:mm:ss AMPM")
MyDate = Format(Date, "Long Date")
If MyTime < "12:00:00 PM" Then
Greetings = "Good Morning"
Else
Greetings = "Good Afternoon"
End If
Dim objMsg As MailItem
Set objMsg = Outlook.CreateItem(olMailItem)
If (Forms("Entry_Log_Form")![Project_Name]) = "RESERVES" Then
With objMsg
.To = "recipent@email.com"
.CC = "recipent@email.com"
.Subject = "Ticket: " & (Forms("Entry_Log_Form")![Ticket_Number]) & " - Project Name: " & (Forms("Entry_Log_Form")![Project_Name])
.Categories = "PROJECTS"
.BodyFormat = olFormatPlain ' send plain text message
.HTMLBody = " Today is " & MyDate & " - " & MyTime & "<br />" & "<br />" & Greetings & "<br />" & "<br />" & " Ticket " & (Forms("Entry_Log_Form")![Ticket_Number]) & " was completed successfully." & "<br />" & "<br />" & "<U>" & "<h4 style=color:red;>" & "TOTALS" & "</h4>" & "</U>" & " " & "Total Items Original File: " & (Forms("Entry_Log_Form")![Number_of_Items]) & "<br />" & " " & "Total Worked Items: " & (Forms("Entry_Log_Form")![Number_of_Items]) & "<br />" & " " & "Total Worked Fields: " & (Forms("Entry_Log_Form")![Number_of_Fields]) & "<br />" & "<br />" & "<U>" & "<h4 style=color:blue;>" & "PROCESSED" & "</h4>" & "</U>" & " " & (Forms("Entry_Log_Form")![Number_of_Fields]) & " Fields" & "<br />" & "<br />" & "<U>" & "<h4 style=color:green;>" & "QUALITY ASSURANCE" & "</h4>" & "</U>" & " " & (Forms("Entry_Log_Form")![Quality_Assurance]) & " Fields" & "<br />" & "<br />" & " Thank You" & "<br />"
.Display
End With
End If
If (Forms("Entry_Log_Form")![Project_Name]) = "RESERVES_88" Then
With objMsg
.To = "recipent@email.com"
.CC = "Vrecipent@email.com"
.Subject = "Ticket: " & (Forms("Entry_Log_Form")![Ticket_Number]) & " - Project Name: " & (Forms("Entry_Log_Form")![Project_Name])
.Categories = "PROJECTS"
.BodyFormat = olFormatPlain ' send plain text message
.HTMLBody = " Today is " & MyDate & " - " & MyTime & "<br />" & "<br />" & Greetings & "<br />" & "<br />" & " Ticket " & (Forms("Entry_Log_Form")![Ticket_Number]) & " was completed successfully." & "<br />" & "<br />" & "<U>" & "<h4 style=color:red;>" & "TOTALS" & "</h4>" & "</U>" & " " & "Total Items Original File: " & (Forms("Entry_Log_Form")![Number_of_Items]) & "<br />" & " " & "Total Worked Items: " & (Forms("Entry_Log_Form")![Number_of_Items]) & "<br />" & " " & "Total Worked Fields: " & (Forms("Entry_Log_Form")![Number_of_Fields]) & "<br />" & "<br />" & "<U>" & "<h4 style=color:blue;>" & "PROCESSED" & "</h4>" & "</U>" & " " & (Forms("Entry_Log_Form")![Number_of_Fields]) & " Fields" & "<br />" & "<br />" & "<U>" & "<h4 style=color:green;>" & "QUALITY ASSURANCE" & "</h4>" & "</U>" & " " & (Forms("Entry_Log_Form")![Quality_Assurance]) & " Fields" & "<br />" & "<br />" & " Thank You" & "<br />"
.Display
End With
End If
If (Forms("Entry_Log_Form")![Project_Name]) = "NON_ACCRUAL_RESERVES" Then
With objMsg
.To = "recipent@email.com"
.CC = "recipent@email.com"
.Subject = "Ticket: " & (Forms("Entry_Log_Form")![Ticket_Number]) & " - Project Name: " & (Forms("Entry_Log_Form")![Project_Name])
.Categories = "PROJECTS"
.BodyFormat = olFormatPlain ' send plain text message
.HTMLBody = " Today is " & MyDate & " - " & MyTime & "<br />" & "<br />" & Greetings & "<br />" & "<br />" & " Ticket " & (Forms("Entry_Log_Form")![Ticket_Number]) & " was completed successfully." & "<br />" & "<br />" & "<U>" & "<h4 style=color:red;>" & "TOTALS" & "</h4>" & "</U>" & " " & "Total Items Original File: " & (Forms("Entry_Log_Form")![Number_of_Items]) & "<br />" & " " & "Total Worked Items: " & (Forms("Entry_Log_Form")![Number_of_Items]) & "<br />" & " " & "Total Worked Fields: " & (Forms("Entry_Log_Form")![Number_of_Fields]) & "<br />" & "<br />" & "<U>" & "<h4 style=color:blue;>" & "PROCESSED" & "</h4>" & "</U>" & " " & (Forms("Entry_Log_Form")![Number_of_Fields]) & " Fields" & "<br />" & "<br />" & "<U>" & "<h4 style=color:green;>" & "QUALITY ASSURANCE" & "</h4>" & "</U>" & " " & (Forms("Entry_Log_Form")![Quality_Assurance]) & " Fields" & "<br />" & "<br />" & " Thank You" & "<br />"
.Display
End With
End If
If (Forms("Entry_Log_Form")![Requestor_Name]) = "FA_PROCESS" Then
If (Forms("Entry_Log_Form")![Project_Name]) = "I1" Or (Forms("Entry_Log_Form")![Project_Name]) = "I2" Or (Forms("Entry_Log_Form")![Project_Name]) = "I3" Then
With objMsg
.To = "recipent@email.com"
.CC = "recipent@email.com"
.Subject = "Ticket: " & (Forms("Entry_Log_Form")![Ticket_Number]) & " - Project Name: " & (Forms("Entry_Log_Form")![Project_Name])
.Categories = "PROJECTS"
.BodyFormat = olFormatPlain ' send plain text message
.HTMLBody = " Today is " & MyDate & " - " & MyTime & "<br />" & "<br />" & Greetings & "<br />" & "<br />" & " Ticket " & (Forms("Entry_Log_Form")![Ticket_Number]) & " was completed successfully." & "<br />" & "<br />" & "<U>" & "<h4 style=color:red;>" & "TOTALS" & "</h4>" & "</U>" & " " & "Total Items Original File: " & (Forms("Entry_Log_Form")![Number_of_Items]) & "<br />" & " " & "Total Worked Items: " & (Forms("Entry_Log_Form")![Number_of_Items]) & "<br />" & " " & "Total Worked Fields: " & (Forms("Entry_Log_Form")![Number_of_Fields]) & "<br />" & "<br />" & " Thank You" & "<br />"
.Display
End With
Else
With objMsg
.To = "recipent@email.com"
.CC = "recipent@email.com"
.Subject = "Ticket: " & (Forms("Entry_Log_Form")![Ticket_Number]) & " - Project Name: " & (Forms("Entry_Log_Form")![Project_Name])
.Categories = "PROJECTS"
.BodyFormat = olFormatPlain ' send plain text message
.HTMLBody = " Today is " & MyDate & " - " & MyTime & "<br />" & "<br />" & Greetings & "<br />" & "<br />" & " Ticket " & (Forms("Entry_Log_Form")![Ticket_Number]) & " was completed successfully." & "<br />" & "<br />" & "<U>" & "<h4 style=color:red;>" & "TOTALS" & "</h4>" & "</U>" & " " & "Total Items Original File: " & (Forms("Entry_Log_Form")![Number_of_Items]) & "<br />" & " " & "Total Worked Items: " & (Forms("Entry_Log_Form")![Number_of_Items]) & "<br />" & " " & "Total Worked Fields: " & (Forms("Entry_Log_Form")![Number_of_Fields]) & "<br />" & "<br />" & "<U>" & "<h4 style=color:blue;>" & "PROCESSED" & "</h4>" & "</U>" & " " & (Forms("Entry_Log_Form")![Number_of_Fields]) & " Fields" & "<br />" & "<br />" & "<U>" & "<h4 style=color:green;>" & "QUALITY ASSURANCE" & "</h4>" & "</U>" & " " & (Forms("Entry_Log_Form")![Quality_Assurance]) & " Fields" & "<br />" & "<br />" & " Thank You" & "<br />"
.Display
End With
End If
GoTo EndOfEmail
End If
If ((Forms("Entry_Log_Form")![Project_Name]) <> "RESERVES" Or (Forms("Entry_Log_Form")![Project_Name]) <> "RESERVES_88" Or (Forms("Entry_Log_Form")![Project_Name]) <> "NON_ACCRUAL_RESERVES") Then
With objMsg
.To = (Forms("Entry_Log_Form")![Requestor_Name])
.CC = "recipent@email.com"
.Subject = "Ticket: " & (Forms("Entry_Log_Form")![Ticket_Number]) & " - Project Name: " & (Forms("Entry_Log_Form")![Project_Name])
.Categories = "PROJECTS"
.BodyFormat = olFormatPlain ' send plain text message
.HTMLBody = " Today is " & MyDate & " - " & MyTime & "<br />" & "<br />" & Greetings & "<br />" & "<br />" & " Ticket " & (Forms("Entry_Log_Form")![Ticket_Number]) & " was completed successfully." & "<br />" & "<br />" & "<U>" & "<h4 style=color:red;>" & "TOTALS" & "</h4>" & "</U>" & " " & "Total Items Original File: " & (Forms("Entry_Log_Form")![Number_of_Items]) & "<br />" & " " & "Total Worked Items: " & (Forms("Entry_Log_Form")![Number_of_Items]) & "<br />" & " " & "Total Worked Fields: " & (Forms("Entry_Log_Form")![Number_of_Fields]) & "<br />" & "<br />" & "<U>" & "<h4 style=color:blue;>" & "PROCESSED" & "</h4>" & "</U>" & " " & (Forms("Entry_Log_Form")![Number_of_Fields]) & " Fields" & "<br />" & "<br />" & "<U>" & "<h4 style=color:green;>" & "QUALITY ASSURANCE" & "</h4>" & "</U>" & " " & (Forms("Entry_Log_Form")![Quality_Assurance]) & " Fields" & "<br />" & "<br />" & " Thank You" & "<br />"
.Display
End With
End If
EndOfEmail:
Set objMsg = Nothing
End Sub