I am trying to add an option to my Access 2000 application that will allow the end user to click a command button that would open up an InputBox so that they could type in an email address, then have Access (working with outlook), open a new mail message, populate the recipient TO field (with the data from the InputBox) and attach the appropriate file to the email body and then send the email to the recipient To address.
I would like this to happen all behind the scenes so to speak (except for the InputBox which should display).
The code I have attached mostly works, except&.
1. Data or email address entered into the InputBox does not get passed through to the email Recipient To field.
2. The email is shown to the end user&waiting for an address to be typed into the TO field, then the end user has to press send.
Im sure it is possible to get this to work but am not familiar with InputBoxes or what happens to the data typed into them and Im fairly novice when it comes to VBA.
The .Recipients.Add sEmailAddress is hidden and all works as described. When I remove the it still works but I get the warning about another application trying to send email&. And then I get You must specify an addresses&&BUT...
Is it possible to get this to pull the data from the InputBox and send the email with attachment immediately with no further interaction from the end user?
Private Sub Command4_Click()
Application.Assistant.AssistWithAlerts = True
Dim olApp As Outlook.Application
Dim olNewMail As Outlook.MailItem
Dim sEmailAddress As String
Dim file As String
Set olApp = New Outlook.Application
Set olNewMail = CreateItem(olMailItem)
Address = InputBox("Type e-mail address")
.Subject = "Worksheet Update"
.Body = "Updated worksheet attached."
.Add "c:\test.doc" 'Attach file (.doc)