• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

SendObject Cause "Illegal Operation Error"

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
WonHop
Asked:
WonHop
  • 5
  • 4
1 Solution
 
PsychoDazeyCommented:
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
 
PsychoDazeyCommented:
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
 
WonHopAuthor Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
PsychoDazeyCommented:
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
 
WonHopAuthor Commented:
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
 
PsychoDazeyCommented:
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
 
WonHopAuthor Commented:
Thanks
0
 
WonHopAuthor Commented:
Hello PsychoDazey.  Sorry I am just now getting back to you.  That solution worked great.
Thanks for all of your help

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

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now