Failed Email Using Outlook

GRose

Registered User.
Local time
Today, 22:37
Joined
Mar 4, 2004
Messages
21
Hello all,

I have a database that automatically sends out emails. This has been working fine until today when I get an error:
Compile Error
User-defined type not defined

The code being used is (not written by me):

Public Sub Send(ByVal Email As String, ByVal Subject As String, ByVal htmlbody As String)

On Error GoTo SendMyEmailError

Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim Subjectline As String

Set MyOutlook = New Outlook.Application
Set MyMail = MyOutlook.CreateItem(olMailItem)

With MyMail
.To = Email
.Subject = Subject
.htmlbody = htmlbody

.Send
End With

Set MyMail = Nothing
Set MyOutlook = Nothing

SendMyEmailError:
Exit Sub

End Sub

Any ideas what the problem is? It worked on Friday and the IT people say there have been no changed to the system.

Thanks
 
Not being very helpful here but maybe if you compact and repair your db and then re-boot your PC it may clear the problem.

It sometimes happens to me, but after compacting my db and restarting my PC it seems to work fine.


Hope this helps.
 
Last edited:
s'not worked. Is doesn't like the Dim MyOutlook to Dim Dim Subjectline part. Can I have a problem with my references?

Ta
 
GRose said:
s'not worked. Is doesn't like the Dim MyOutlook to Dim Dim Subjectline part. Can I have a problem with my references?

Ta

I use Groupwise not Outlook for my email system and I have the following references set :

  • Visual Basic for Applications
  • Microsoft Access 9.0 Object library

  • Microsoft DAO 3.6 Object Library

  • OLE Automation

  • Microsoft Active X Data Object 2.1 Library

not sure if this will make any difference though.
 
In the VB Window Check you have references set to the Outlook 9.0 (Access 2K) Library or Outlook 10 (Access XP) Library.
If it shows up as missing then deselect the library and then reselect it.
 

Users who are viewing this thread

Back
Top Bottom