Hi,
I am trying to automatically send a confirmation # email after placing an order. I have the orders placed on a form with a command button that will start the event procedure. However, when I run this code, I get a run-time error message: Outlook does not recognize one or more names. Then when I go to debug it - the arrow points to the .send part of my code. I am using Acess 2003 and MS Outlook. Does anyone know what I'm doing wrong?
Private Sub Command96_Click()
Dim EmailAddress As String
Dim Autonumber As String
Dim Text97 As String
'Create variables for Outlook
Dim objOutlook As Outlook.Application
Dim objemail As Outlook.MailItem
'Gather information from form.
EmailAddress = Me!EmailAddress
Autonumber = Me!Autonumber
Text97 = Me!Text97
'Creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objemail = objOutlook.CreateItem(olMailItem)
'Creates and send email
With objemail
.To = EmailAddress
.Subject = Autonumber
.Body = Text97
.Send
End With
'Closes outlook
Set objemail = Nothing
objOutlook.Quit
End Sub
I am trying to automatically send a confirmation # email after placing an order. I have the orders placed on a form with a command button that will start the event procedure. However, when I run this code, I get a run-time error message: Outlook does not recognize one or more names. Then when I go to debug it - the arrow points to the .send part of my code. I am using Acess 2003 and MS Outlook. Does anyone know what I'm doing wrong?
Private Sub Command96_Click()
Dim EmailAddress As String
Dim Autonumber As String
Dim Text97 As String
'Create variables for Outlook
Dim objOutlook As Outlook.Application
Dim objemail As Outlook.MailItem
'Gather information from form.
EmailAddress = Me!EmailAddress
Autonumber = Me!Autonumber
Text97 = Me!Text97
'Creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objemail = objOutlook.CreateItem(olMailItem)
'Creates and send email
With objemail
.To = EmailAddress
.Subject = Autonumber
.Body = Text97
.Send
End With
'Closes outlook
Set objemail = Nothing
objOutlook.Quit
End Sub