Solved

SendObject Cause "Illegal Operation Error"

Posted on 2001-06-21
9
205 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
 
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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 views 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 Microsoft Access…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now