Hi, I am new to this forum and to Access, i have very limited knowledge of VBA and am currently teaching myself how to find my way around Access. I have currently got the following set up:
Tables
Public Function Email1(ByVal pvTo, ByVal pvSubj, ByVal pvBody, ByVal pvFile) As Boolean
Dim oApp As Outlook.Application
Dim oMail As Outlook.MailItem
On Error GoTo ErrMail
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(olMailItem)
With oMail
.To = pvTo
.Subject = pvSubj
If Not IsNull(pvBody) Then .Body = pvBody
If Not IsEmpty(pvFile) Then .Attachments.Add pvFile, olByValue, 1
.Send
End With
Email1 = True
Set oMail = Nothing
Set oApp = Nothing
Exit Function
ErrMail:
MsgBox Err.Description, vbCritical, Err
Resume Next
End Function
and then added the following to the On Click tab in properties:
Call Email1("bob@co.com", 'Ticket Raised By: BOB", [descrption])
however i am getting the following error message:
Microsoft Access cannot find the object 'Call Email1 (bob@co.'If 'Call Email1("bob
co' is a new macro or macro group, make sure you have saved it and that you have typed its name correctly.
This is not code that i have thought up myself it was on the advise of someone else however i really dont know how to resolve the error message.
I would really appreciate any help given
Many thanks
AJ
Tables
- AccessControl
- HelpdeskTickets
- LeaverRequest
- Users
- AccessControlRequest
- NewTicket
- NewUser
- Brief Description
- TicketID
- Ticket Raised by
- Assigned to
- Opened by
- Opened date
- Due date
- Priority
- Status
- Category
- Referred
- Dept ref
- Full description
- Comments
Public Function Email1(ByVal pvTo, ByVal pvSubj, ByVal pvBody, ByVal pvFile) As Boolean
Dim oApp As Outlook.Application
Dim oMail As Outlook.MailItem
On Error GoTo ErrMail
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(olMailItem)
With oMail
.To = pvTo
.Subject = pvSubj
If Not IsNull(pvBody) Then .Body = pvBody
If Not IsEmpty(pvFile) Then .Attachments.Add pvFile, olByValue, 1
.Send
End With
Email1 = True
Set oMail = Nothing
Set oApp = Nothing
Exit Function
ErrMail:
MsgBox Err.Description, vbCritical, Err
Resume Next
End Function
and then added the following to the On Click tab in properties:
Call Email1("bob@co.com", 'Ticket Raised By: BOB", [descrption])
however i am getting the following error message:
Microsoft Access cannot find the object 'Call Email1 (bob@co.'If 'Call Email1("bob
co' is a new macro or macro group, make sure you have saved it and that you have typed its name correctly.
This is not code that i have thought up myself it was on the advise of someone else however i really dont know how to resolve the error message.
I would really appreciate any help given
Many thanks
AJ