I am using Access 2003 and want to add the Outlook library so that I can work with sending emails. My instructions say to use Tools / References but I don't see that in Access 2003. How do I add the Outlook library?
Robert
Robert
What are code tags? I am not familiar with that.
Public Function fYearsMonths(dteStart As Date, dteEnd As Date) As String
Dim i As Integer, intMonths As Integer, intYears As Integer
Dim strMonths As String, strYears As String
i = DateDiff("m", dteStart, dteEnd) + _
(dteEnd < DateSerial(Year(dteEnd), Month(dteEnd), Day(dteStart)))
intYears = Fix(i / 12)
intMonths = i Mod 12
strYears = IIf(intYears = 1, " year ", " years ")
strMonths = IIf(intMonths = 1, " month", " months")
fYearsMonths = IIf(intYears = 0, "", intYears & strYears) & intMonths & strMonths
End Function
[FONT=Arial]'The sub procedure below sends e-mail in response to a click on the Send button.[/FONT]
[FONT=Arial]Private Sub SendMessagesButton_Click()[/FONT]
[FONT=Arial][/FONT]
[FONT=Arial]'For Access, define some object variables and make connections.[/FONT]
[FONT=Arial]Dim myConnection As ADODB.Connection[/FONT]
[FONT=Arial]Set myConnection = CurrentProject.Connection[/FONT]
[FONT=Arial]Dim myRecordSet As New ADODB.Recordset[/FONT]
[FONT=Arial]myRecordSet.ActiveConnection = myConnection[/FONT]
[FONT=Arial][/FONT]
[FONT=Arial]'Define some object variables for Outlook[/FONT]
[FONT=Arial]Dim appOutlook As Outlook.Application 'Refers to Outlook's Application object.[/FONT]
[FONT=Arial]Dim appOutlookMsg As Outlook.MailItem 'Refers to an Outlook e-mail message.[/FONT]
[FONT=Arial]Dim appOutlookRecip As Outlook.Recipient 'Refers to an Outlook e-mail recipient.[/FONT]
[FONT=Arial][/FONT]
[FONT=Arial]'General variables.[/FONT]
[FONT=Arial]Dim mySQL As String, eMailAddress As String, whereClause As String[/FONT]
[FONT=Arial]Dim myMsg As String[/FONT]
The X will be a number that is dependant on your version of Office (I think it's 10 for 2003).
Here is the code that I am having problems with:
Code:[FONT=Arial][FONT=Arial]'The sub procedure below sends e-mail in response to a click on the Send button.[/FONT] [FONT=Arial]Private Sub SendMessagesButton_Click()[/FONT] [FONT=Arial]'For Access, define some object variables and make connections.[/FONT] [FONT=Arial]Dim myConnection As ADODB.Connection[/FONT] [FONT=Arial]Set myConnection = CurrentProject.Connection[/FONT] [FONT=Arial]Dim myRecordSet As New ADODB.Recordset[/FONT] [FONT=Arial]myRecordSet.ActiveConnection = myConnection[/FONT] [FONT=Arial]'Define some object variables for Outlook[/FONT] [FONT=Arial]Dim appOutlook As Outlook.Application 'Refers to Outlook's Application object.[/FONT] [FONT=Arial]Dim appOutlookMsg As Outlook.MailItem 'Refers to an Outlook e-mail message.[/FONT] [FONT=Arial]Dim appOutlookRecip As Outlook.Recipient 'Refers to an Outlook e-mail recipient.[/FONT] [FONT=Arial]'General variables.[/FONT] [FONT=Arial]Dim mySQL As String, eMailAddress As String, whereClause As String[/FONT] [FONT=Arial]Dim myMsg As String[/FONT] [/FONT]
The error message I am getting is 'Compile error: User-defined type'. I am getting that on the line: Dim appOutlook as Outlook.Application.
I do have Outlook selected on the references list.
Robert
How do I make a pic of my references list to post here?
Robert
So, you said that you had Outlook checked.I don't have SnipTool on the server that hosts my application. Also I don't have PrtScrn on my Mac keyboard - I am running Windows 7 on an iMac.
So here is a list of my checked references:
Visual Basic for Applications
Microsoft Access 11.0 object library
OLE automation
Microsoft DAO 3.6 object library
Microsoft ActiveX data obbjects 2.5 library
Microsoft Windows common controls 6.0 (SP6)
Microsoft calendar control 11.0
Robert