Hi All,
currently i have my Submit button set to email a notification, the button gets clicked, email is sent to me.
the issue with this is the email is sent event if there is an error, (duplicate validation failed, empty field that must be filled in, etc)
i want the email to only be sent on a successful update from my userform, not every time the button is clicked
currently i have my Submit button set to email a notification, the button gets clicked, email is sent to me.
the issue with this is the email is sent event if there is an error, (duplicate validation failed, empty field that must be filled in, etc)
i want the email to only be sent on a successful update from my userform, not every time the button is clicked
VBA Code:
Private Sub cmdSubmit_Click()
Application.EnableEvents = False
Dim msgvalue As VbMsgBoxResult
msgvalue = MsgBox("Do you want to save the data?", vbYesNo + vbInformation, "confirmation")
If msgvalue = vbNo Then Exit Sub
If ValidateEntries() = True Then
Call Submit
Call reset
End If
'email notification
Dim xOutApp As Object
Dim xOutMail As Object
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
On Error Resume Next
With xOutMail
'.To = "MarkP@bapcor.com.au; markjpollock91@gmail.com"
.To = "MarkP@Bapcor.com.au"
.CC = ""
.BCC = ""
.Subject = "WMS LOGIN REGISTER"
.Body = "Account Creation Requested By " & (Application.UserName)
.Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
Application.EnableEvents = True
End Sub