I want to have a button on an 'admin' form whereby the user of the database would click the button and a blank email would open in Outlook for the user to enter his/her problem into. But I want the 'to' email address and subject to be already present in the new email.
If the Outlook program is closed, when the user clicks the button I also want Outlook to open and the blank email with subject and 'to' address filled in.
I have the code below but when I click the button it, 1. doesnt open outlook and 2. sends the email without allowing someone to edit it.
Can someone please help!!
Expand|Select|Wrap|Line Numbers
- Private Sub cmdemail_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") 'this checks if outlook is open
- If Error Then 'if outlook is not open then do the following
- Set olApp = CreateObject("Outlook.Application")
- End If
- 'creating the email item
- Set objMail = olApp.CreateItem(olMailItem)
- With objMail
- 'then need to set the body the HTML format
- .BodyFormat = olFormatHTML
- .To = "david.everson@reemtsma.de"
- .Subject = "Product Development Ink and Varnish Database Help"
- .HTMLBody = "<htmltags>Thank you for your email. Please include a brief description of your problem below. I aim to respond to all problems within 3 working days</htmltags>"
- .send
- End With
- End Sub