Hello,
I have implemented a process within my Access 2000 application (with tons of help and info from the experts on this site!) that automatically sends an email to a specified recipient using fields from one of the forms within the application. The process works very well with one exception. I would like to be able to provide my users with the ability to enter a new new email recipient if the person specified by my code is not who they would like to send the email to. This situation does not happen often, but there are times when staff members cover off for each other and as such, would need to enter a new email recipient. I have attached my code for review and would appreciate any feedback/suggestions:
Private Sub cmdSendEmail_Click()
'Begin Code
'Declare Variables
Dim strSubject As String
Dim strBody As String
Dim strRFCStatus As String
Dim strCCMNumber As String
Dim strRFCNumber As String
Dim strRecipient As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'Change RFC Status Code to the full text description
strRFCStatus = Me!RFCStatusCode
If Me!RFCStatusCode = "AI" Then
strRFCStatus = "Approved for Implementation"
ElseIf Me!RFCStatusCode = "CA" Then
strRFCStatus = "Cancelled"
ElseIf Me!RFCStatusCode = "CL" Then
strRFCStatus = "Closed"
ElseIf Me!RFCStatusCode = "DE" Then
strRFCStatus = "Deferred"
ElseIf Me!RFCStatusCode = "NE" Then
strRFCStatus = "New"
ElseIf Me!RFCStatusCode = "NA" Then
strRFCStatus = "Not Approved"
ElseIf Me!RFCStatusCode = "OA" Then
strRFCStatus = "Open for Impact Analysis"
ElseIf Me!RFCStatusCode = "RM" Then
strRFCStatus = "RFC Returned for Modification"
End If
'Set references to the form objects
strBody = strBody & "CCM OPI:" & " " & Me!CMTOPI & Chr(13) & Chr(10) & Chr(10)
strBody = strBody & "RFC Status:" & " " & strRFCStatus & Chr(13) & Chr(10)
strBody = strBody & "RFC Class:" & " " & Me!ScopeAssessment & Chr(13) & Chr(10)
strBody = strBody & "RFC Priority:" & " " & Me!ChangePriority & Chr(13) & Chr(10)
strBody = strBody & "ECS/GP Name:" & " " & Me!Group & Chr(13) & Chr(10) & Chr(10)
strBody = strBody & "CCM Notification Coordinator:" & " " & "DavisPA"
strCCMNumber = Me!Reference
strRFCNumber = Me!IMCCB
strSubject = "CM" & " " & Me!Reference & "," & " " & Me!Group & "," & " " & Me!ScopeAssessment & "," & " " & "RFC" & " " & Me!IMCCB & "," & " " & strRFCStatus & "," & " " & Me!ProjectTitle
'Create Instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'Create and Send Email
With objEmail
.To = "Rivard JMR@ADM(IM) 76 Comm Gp@Ottawa-Hull"
.Subject = strSubject
.Body = strBody
.Send
End With
'Close Outlook
Set objEmail = Nothing
'objOutlook.Quit
Exit Sub
'End Code
End Sub
I have implemented a process within my Access 2000 application (with tons of help and info from the experts on this site!) that automatically sends an email to a specified recipient using fields from one of the forms within the application. The process works very well with one exception. I would like to be able to provide my users with the ability to enter a new new email recipient if the person specified by my code is not who they would like to send the email to. This situation does not happen often, but there are times when staff members cover off for each other and as such, would need to enter a new email recipient. I have attached my code for review and would appreciate any feedback/suggestions:
Private Sub cmdSendEmail_Click()
'Begin Code
'Declare Variables
Dim strSubject As String
Dim strBody As String
Dim strRFCStatus As String
Dim strCCMNumber As String
Dim strRFCNumber As String
Dim strRecipient As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'Change RFC Status Code to the full text description
strRFCStatus = Me!RFCStatusCode
If Me!RFCStatusCode = "AI" Then
strRFCStatus = "Approved for Implementation"
ElseIf Me!RFCStatusCode = "CA" Then
strRFCStatus = "Cancelled"
ElseIf Me!RFCStatusCode = "CL" Then
strRFCStatus = "Closed"
ElseIf Me!RFCStatusCode = "DE" Then
strRFCStatus = "Deferred"
ElseIf Me!RFCStatusCode = "NE" Then
strRFCStatus = "New"
ElseIf Me!RFCStatusCode = "NA" Then
strRFCStatus = "Not Approved"
ElseIf Me!RFCStatusCode = "OA" Then
strRFCStatus = "Open for Impact Analysis"
ElseIf Me!RFCStatusCode = "RM" Then
strRFCStatus = "RFC Returned for Modification"
End If
'Set references to the form objects
strBody = strBody & "CCM OPI:" & " " & Me!CMTOPI & Chr(13) & Chr(10) & Chr(10)
strBody = strBody & "RFC Status:" & " " & strRFCStatus & Chr(13) & Chr(10)
strBody = strBody & "RFC Class:" & " " & Me!ScopeAssessment & Chr(13) & Chr(10)
strBody = strBody & "RFC Priority:" & " " & Me!ChangePriority & Chr(13) & Chr(10)
strBody = strBody & "ECS/GP Name:" & " " & Me!Group & Chr(13) & Chr(10) & Chr(10)
strBody = strBody & "CCM Notification Coordinator:" & " " & "DavisPA"
strCCMNumber = Me!Reference
strRFCNumber = Me!IMCCB
strSubject = "CM" & " " & Me!Reference & "," & " " & Me!Group & "," & " " & Me!ScopeAssessment & "," & " " & "RFC" & " " & Me!IMCCB & "," & " " & strRFCStatus & "," & " " & Me!ProjectTitle
'Create Instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'Create and Send Email
With objEmail
.To = "Rivard JMR@ADM(IM) 76 Comm Gp@Ottawa-Hull"
.Subject = strSubject
.Body = strBody
.Send
End With
'Close Outlook
Set objEmail = Nothing
'objOutlook.Quit
Exit Sub
'End Code
End Sub