Solved

SendObject Cause "Illegal Operation Error"

Posted on 2001-06-21
9
206 Views
Last Modified: 2009-12-16
Hello.  I created a database in Access 97.  It has since been upgraded to Access 2000.  I am not really sure when the problem started since I am not over the database any more.  I got a call from the girl who upgraded and is now working on it.

There is a button that sends email under certain conditions.  For some reason when it get to the SendObject, it gives the error message "Illegal Operation and then the database shuts down.

Are there any References that need to be changed other than the Access 9.0?
I will appreciate any help.  But it might be Monday or so before I can get back with every one.  The database is in another building here on site. I am still using Access 97 so I will have to go over there to try any suggestions.  I will try to exlpain them to the girl over the phone first.

WonHop
0
Comment
Question by:WonHop
  • 5
  • 4
9 Comments
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 6216516
If she upgraded to a2000, she may have also upgraded to outlook 2000.  Make sure the references are set for the latest version of outlook.
I am sending some code after this comment that will do the trick if that doesn't work.
0
 
LVL 6

Accepted Solution

by:
PsychoDazey earned 150 total points
ID: 6216528
This is using outlook to send the email.
Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
          Dim objOutlook As Outlook.Application
          Dim objOutlookMsg As Outlook.MailItem
          Dim objOutlookRecip As Outlook.Recipient
          Dim objOutlookAttach As Outlook.Attachment

          Set objOutlook = CreateObject("Outlook.Application")

          Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

          With objOutlookMsg
              ' Add the To recipient(s)
              Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
              objOutlookRecip.Type = olTo

              ' Add the CC recipient(s)
              Set objOutlookRecip = .Recipients.Add("Michael Suyama")
              objOutlookRecip.Type = olCC

             ' Add the BCC recipient(s)
              Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
              objOutlookRecip.Type = olBCC

             ' Set the Subject, Body, and Importance
             .Subject = "This is an Automation test with Microsoft Outlook"
             .Body = "This is the body of the message." & vbCrLf & vbCrLf
             .Importance = olImportanceHigh  'High importance

             ' Add attachments
             If Not IsMissing(AttachmentPath) Then
                 Set objOutlookAttach = .Attachments.Add(AttachmentPath)
             End If

             ' Resolve each Recipient's name.
             For Each objOutlookRecip In .Recipients
                 objOutlookRecip.Resolve
             Next

             ' Display the message before sending?
             If DisplayMsg Then
                 .Display
             Else
                 .Save
                 .Send
             End If
          End With
          Set objOutlook = Nothing
      End Sub
0
 
LVL 2

Author Comment

by:WonHop
ID: 6218430
Thanks for responding PsychoDazey.

They were already using Office 2000.  They considered the Access Licences to expensive to give to everyone, so they held Access 2000 back until recently.  That is when they upgraded the database.  So the references were already set for Outlook 2000.  She says that it worked for a while in Access 2000.  I cannot verify that.  
Could the database be corrupted or damaged in some way.
Are there any Access 2000 references like from DAO to ADO or something like that?  Something that needs to be added to Access 2000 that Access 97 did not need?

Regarding your comment.  I see how it works.  Writing the code the way you have it here, does that keep you from having to use the SendObject Function or is this another way of writing the SendOject?

WonHop
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 6

Expert Comment

by:PsychoDazey
ID: 6218576
You dont have to use the sendobject function with that code, it uses the outlook object.  You will have to set a reference to Outlook to use it.
Maybe you should try changing which version of DAO you are referencing?  i.e.- if you are referencing 3.6, change to 3.51 or 2.51 - 3.51
0
 
LVL 2

Author Comment

by:WonHop
ID: 6218615
Thanks PsychoDazey.  I will send the infomation over there.  Like I said earlier, I might have to go over and do it.  It might be later today or more like Monday.  I would like to thank you in advance for your patience.

I am trying to get another project that I am working on to the point where I can ask another question about a Where Clause and get it solved first.

Thanks
WonHop
0
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 6218645
No problem, I have a cd full of sample code for manipulating outlook within access, so let me know if you need more help with this.
0
 
LVL 2

Author Comment

by:WonHop
ID: 6218729
Thanks
0
 
LVL 2

Author Comment

by:WonHop
ID: 6233049
Hello PsychoDazey.  Sorry I am just now getting back to you.  That solution worked great.
Thanks for all of your help

WonHop
0
 
LVL 6

Expert Comment

by:PsychoDazey
ID: 6233438
Thats ok, I've been travelling all week anyway.  I am glad the code worked out for you!
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question