I do not know a lot about VBA coding. but here is my problem: I have had an Access 2003 DB and am using it to send emails to clients using fields from the form with code adapted from a tutorial found on this site.
I am trying to upgrade to Access 2007. If I use Access to open my old database in the email works fine.
I am creating a new database in 2007 and the same code returns a VBA error:
"Compile Error: User defined type not defined.
The VBA window highlights this line:
Dim objOutlook As Outlook.Application - as the offending code.
The entire code for the subroutine is:
Can anyone help me get this working?
Thanks in advance
I am trying to upgrade to Access 2007. If I use Access to open my old database in the email works fine.
I am creating a new database in 2007 and the same code returns a VBA error:
"Compile Error: User defined type not defined.
The VBA window highlights this line:
Dim objOutlook As Outlook.Application - as the offending code.
The entire code for the subroutine is:
Code:
Private Sub CCC_Email_Click()
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Dim email As String
Dim ref As String
Dim FirstName As String
Dim CaseNO As String
Dim hearingdate As String
Dim hearingtime As String
Dim bodyNotes1 As String
Dim bodyNotes2 As String
Dim bodyNotes3 As String
'**gathers information from your form. this sets the string variable to your fields
email = Me!Client_email
ref = Me!LastName
FirstName = Me!FirstName
CaseNO = Me!Case_No
hearingdate = Me!Creditors_Exam_Date
hearingtime = Me!Creditors_Exam_Time
bodyNotes1 = “ text"
bodyNotes2 = "<P><font size = ""3"">some text.<P>The website address is: <a href=""[URL unfurl="true"]http://www.xxxxxxxxx.com"">xxxxxxxxxx.com</a>[/URL] <P>text- text. </html>"
bodyNotes3 = ""
'***creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'***creates and sends email
With objEmail
.To = email
.Subject = "Reminder to Complete Credit Counseling for " & ref & ", " & FirstName & "; " & "fromxx."
.HTMLBody = bodyNotes1 & bodyNotes2
.ReadReceiptRequested = True
.Display 'sends the email in Outlook. Change to DISPLAY if you want to be able to
'modify or see what you have created before sending the email
'**closes outlook
'**objOutlook.Quit
'**Set objEmail = Nothing
Exit Sub
End Sub
Thanks in advance