SendObject Cause "Illegal Operation Error"

Posted on 2001-06-21
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.

Question by:WonHop
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4

Expert Comment

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.

Accepted Solution

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

             ' Display the message before sending?
             If DisplayMsg Then
             End If
          End With
          Set objOutlook = Nothing
      End Sub

Author Comment

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?

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.


Expert Comment

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

Author Comment

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.


Expert Comment

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.

Author Comment

ID: 6218729

Author Comment

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


Expert Comment

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

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

726 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