Hello,
Firstly I know this doesn't work as I have taken bits of code from here, there, and everywhere.
I was hoping to get the code cleaned up and working for me
It needs to look at the form and specific fields to be able to gather the required information and insert into an email.
Thank you.
Firstly I know this doesn't work as I have taken bits of code from here, there, and everywhere.
I was hoping to get the code cleaned up and working for me
It needs to look at the form and specific fields to be able to gather the required information and insert into an email.
Code:
' Ask if to send email to Project Manager, Yes: Look up PM and get email.
' Check for email first, if empty open PM contact record to enter email.
Public Function PmEmail()
Dim txtmessage As String
Dim iResponse As String
Dim Msg As String
Dim rs As Recordset
Dim O As Outlook.Application
Dim m As Outlook.MailItem
txtmessage = MsgBox("Do you wish to notify Project Manager of date change?", vbYesNo, "Email Project Manager")
Select Case iResponse
Case vbYes:
' Check if email address in EmployeeT for PM
' PM Name/ID is from form (TxtProjectManager)
Set rs = CurrentDb.OpenRecordset("Select * from EmployeeT_EmailWork")
' PM Name/ID is from form (TxtProjectManager)
Msg = "Hello (TxtProjectManager),<p>" & _
"Please be advised of date change for Job# (TxtJobNumber), Entry ID (JobID),<p>" & _
"Job Reference (TxtReference), New Delivery date (TxtCustomerPreferredDate), Thank you."
Set O = New Outlook.Application
Set m = O.CreateItem(olMailItem)
With m
.BodyFormat = olFormatHTML
.HTMLBody = Msg
.To = "(EmployeeT_EmailWork)"
'.CC = ""
'.BCC = ""
.Subject = "Job# (TxtJobNumber), Entry ID (JobID), Notification of Date Change" & " " & Now()
.Display
'.Send
End With
Set m = Nothing
Set O = Nothing
Case vbNo:
End Select
End Function
Thank you.