I have some code that sends an email when the database is registered. The problem is that depending on a users security settings on their PC they can stop the email from being sent (2007) How can I add to the code to make it check that the user hadnt cancelled the email?
My code is:
My code is:
Code:
Private Sub btnRegister_Click()
Dim olApp As Object
Dim objMail As Object
On Error Resume Next 'Keep going if there is an error
Set olApp = GetObject(, "Outlook.Application") 'See if Outlook is open
If Err Then 'Outlook is not open
Set olApp = CreateObject("Outlook.Application") 'Create a new instance
End If
DoCmd.Hourglass True
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)
With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.To = "da.drew@hotmail.co.uk"
.Subject = "Gundog Manager Registration"
.HTMLBody = "<HTMLtags>This email confirms that a new user " & _
olApp.Application.Session.Accounts.Item(1).SmtpAddress & _
" has registered a copy of Gundog Manager. The registration number of this copy is " & Me.RegistrationNumber & "</HTMLtags>"
.Send
End With
DoCmd.Hourglass False
MsgBox "Operation completed successfully"
Me.chkboxRegistar = True
Me.Requery
End Sub