Link to home
Start Free TrialLog in
Avatar of bfuchs
bfuchsFlag for United States of America

asked on

Docmd.SendObject stopped to work after installing Outlook 2016

Hi Experts,

We have an Access app that is used with Access 2007

The docmd.SendObject to send emails stopped working since we upgraded our Outlook to 2016.

We're getting the attached error msg.User generated image
Any way to make this work again?
Avatar of Mike McCracken
Mike McCracken

Not sure if this is the issue but we had a similar issue several years ago and had to set a flag in Outlook to allow an application to send an email.

I don't recall where that flag was but it was added to prevent untrusted applications from sending emails (spam)

mlmcc
Avatar of bfuchs

ASKER

Hi

I wanted to do that but its grayed out.
See attached.

Thanks,
Ben
Untitled.png
Can you post the code, and let us know what line the error occurs on?
Anything else change, like the location of the database?

Might review the Trusted Locations to ensure the Access db is located in one.
Avatar of bfuchs

ASKER

@Jeff,
    DoCmd.SendObject , , , , , , Trim(Me.FirstName & " " & Me.LastName), "Received documents."

Open in new window

@Scott,
Nothing at all changed besides upgrading the office to 2016 (except Access which 2007 is still in use).
Will see if trusted location helps..


Thanks,
Ben
Avatar of bfuchs

ASKER

@Scott,

Is there a way I can add a location to the trusted locations using A2003 (I use that for programming)?

Thanks,
Ben
Just for fun, try sending a report with all the major arguments filled in:

DoCmd.SendObject acSendReport, "rptTest", acFormatRTF, "YourEmailAddressHere", , , "Test Subject", "Test Message"

It may also be that the "event" you are using is no longer valid for sending emails...?
What event are you using? (was this same event code working in the previous version?)

...and what "state" is your application in when it errors?
Perhaps the current record was not saved/committed when your code runs...?

I tested code, like what I suggested above, in 2016 and it worked fine.

Also try running the Compact and Repair utility in the DB.

JeffCoachman
Avatar of bfuchs

ASKER

Hi Experts,
Might review the Trusted Locations to ensure the Access db is located in one.
That didn't help..
Just for fun, try sending a report with all the major arguments filled in:..
Didnt work either..
I tested code, like what I suggested above, in 2016 and it worked fine.
Perhaps the reason is that its an ADP and users are forced to use A2007, while the rest office got upgraded to 2016?
(was this same event code working in the previous version?)
Just reassuring, everything in the app is the same, nothing changed besides the new Outlook.

Thanks,
Ben
When trying to do this, do you have to add the Outlook library or assembly to Access?  The reference to it may need to be updated.

mlmcc
Avatar of bfuchs

ASKER

@mincc,

1- We do have reference to Outlook 16.0 library.
2- Besides the docmd.SendObject never required a reference to extra libraries, as was built into Access defaults..

Thanks,
Ben
Been a long time since I did it so wasn't sure.

mlmcc
SendObject doesn't require a reference. Are you also using code that requires that Outlook 2016 reference?

Much as I hate to say it (and you to hear it), you may be running into issues with that .adp format in newer versions. As you're aware, MSFT stopped supporting the .adp format as of Access 2013 (https://msdn.microsoft.com/en-us/library/office/jj618413.aspx), so no regression testing would be performed for newer versions of Access. If it works in 2007, but not 2016, it's something to consider.
Avatar of bfuchs

ASKER

@Scott,

This has nothing to do with the file being an ADP.

Just tested with an A2003 MDB and the same is happening there.

See attached.

Thanks,
Ben
Untitled.png
This has nothing to do with the file being an ADP.

Just tested with an A2003 MDB and the same is happening there.
Same could be said of the .mdb/.mde format as with the .adp - incompatibility between a very old format and the new version of Outlook.

Just curious - what happens if you run that code in a .accdb format file with 2016? I use SendObject regularly with .accdb formatted files, but I haven't run into the scenario where I have an older .mdb or .adp format file with 2016.
Avatar of bfuchs

ASKER

Hi Scott,

Sorry for my late response.

Just curious - what happens if you run that code in a .accdb format file with 2016?
My PC only has A2003, hope to get hold of a later version tom & test this out.

Thanks,
Ben
Avatar of bfuchs

ASKER

@Scott,

I got to test at another pc with Outlook 2016 and it worked with all versions MDB and ACCDB.

I also tried with that pc using A2003 in an MDB file and also worked.

So I am kind of confused, what exactly is causing my pc (same as a couple of other users) this error?

Thanks,
Ben
I got to test at another pc with Outlook 2016 and it worked with all versions MDB and ACCDB.
Then it would seem it does work, but only on certain machines.

About the only thing I could suggest would be to compare actual versions of all relevant pieces to see if they are all compatible. For example, in Access 2016 I can look at the Account page and see that I'm running "Microsoft Office Professional Plus, Version 1710, Built 8625.2127". Compare those, and see if something is amiss with the trouble machines.

Also, it could be something entirely different - for example, the version of DAO/JET/ACE on each machine. Unfortunately, when trying to troubleshoot issues like this on unsupported platforms, it's kinda hard to figure out what "correct" is.
Avatar of bfuchs

ASKER

Hi,

For example, in Access 2016 I can look at the Account page and see that I'm running "Microsoft Office Professional Plus, Version 1710, Built 8625.2127". Compare those
Not sure where do I find this account page.
But really I need it in A2007 to work, so would need to know where can I find this info there as its not between the main menus.

Thanks,
Ben
You get to a bit differently in 2007. Click the big Office button >> Access >> Resources. There should be an "About" section on the page with version and build information.
Avatar of bfuchs

ASKER

Ok,

The trouble one is Access 2007 12.0.4518.1014

The good is currently offline..will try to get to it tom.
But that one also has A2013, perhaps this also matters?
Also, it could be something entirely different - for example, the version of DAO/JET/ACE on each machine
How do I figure out this?

Thanks,
Ben
Only way to do that would be to create a machine with the barebones on it (Windows and Office) and then add other components (or other combinations of components) until you figure out which one causes the troubles. This can be a long and difficult path, of course.

Be sure all machines are fully up to date on all relevant pieces of software (Windows, Office, etc).

Try temporarily turning off antivirus to see if that is the culprit (long shot, but ya never know).
Avatar of bfuchs

ASKER

Hi,
Try temporarily turning off antivirus to see if that is the culprit (long shot, but ya never know).
Tried that, didnt help-:(

Still waiting to get on the working pc again to do the comparison.

Thanks,
Ben
Avatar of bfuchs

ASKER

@Scott,

From all the people I saw in google complaining about this error, so far the only one posted solution was the following
https://www.access-programmers.co.uk/forums/showthread.php?t=277995
Thank you for your help, Everyone! I appear to have solved the problem.

I noticed that the access wizards were not working this afternoon (I used a query wizard to start the structure of an SQL statement). That made me think that my copy of Access had somehow become corrupted.

Using the Windows Add/Remove programs feature, I repaired Runtime 2013 and did a quick repair of my copy of Office 365. After that, SendObject commands worked as they had in the past..
Then I realized my link table manager is also not working, tried office repair & didnt help, didnt restore my link table wizard either...

Thanks,
Ben
Avatar of bfuchs

ASKER

I tried creating a replacement as follows

Public Sub MySendObject(sTo As String, sSub As String, sCC As String, sBcc As String, ByVal shtmlBody As String)
 Dim outApp As Outlook.Application, outMsg As MailItem
 Dim itm As Variant
 On Error GoTo err
 Set outApp = CreateObject("Outlook.Application")
 Set outMsg = outApp.CreateItem(olMailItem)

    With outMsg
        
        .To = sTo
        .CC = sCC
        .BCC = sBcc
        .Subject = sSub
         .Body = shtmlBody
       ' .htmlBody = shtmlBody
'        .ReadReceiptRequested = True
'        .send
        
    End With

Set outApp = Nothing
Set outMsg = Nothing
ErrExit:

Exit Sub
err:
    MsgBox err.Description
    GoTo ErrExit
End Sub

Open in new window

Something that worked with previous versions, but now I get error msg "Error loading DLL"

We do have reference to latest Outlook library, see attached.

Thanks,
Ben
Untitled.png
If you're running 2007 or greater, be sure the folder hosting the database is added as a Trusted Location. Not sure if those can get screwed up if you upgrade Outlook or not, but it's worth a look. Of course, anything below 2007 didn't use Trusted Locations.

If you're going to automate Outlook, you don't need a reference to Outlook. Late Binding techniques use whatever version of Outlook is on the machine.
Avatar of bfuchs

ASKER

Hi Scott,

All users had their pwd changed this week, could not get hold of any A2007 - O2016 pc yet, hope to test that on Sunday.

However in my scenario where I have A2003 and Outlook 2016, is there a way to make that work?

I would be satisfied if any of these work, either SendObject or the function I posted above (ID: 42410005
) to substitute that.

Thanks,
Ben
Avatar of bfuchs

ASKER

Hi Scott,

I just got hold of pc A2007 O2016 and

1- Tested with application under trusted location, didnt help.

2- When tested the MySendObject posted above it did work, however its just sending the msg, and what we really want is opening the Outlook editor where users can edit the msg, just the way sendObject used to work.

Please let me know how to proceed.

Thanks,
Ben
Try specifically including the EditMessageargument:

DoCmd.SendObject , , , , , , Trim(Me.FirstName & " " & Me.LastName), "Received documents.", True

You might also consider including other items, like acSendNoObject. Sometimes, code that worked perfectly fine in 2003 would have troubles in later versions, and specifically specifying optional arguments seemed to help.
Avatar of bfuchs

ASKER

Hi,

Try specifically including the EditMessageargument:
This one works for A2003 but not for A2007.

So at least we/re getting closer to solve it-:)

Thanks,
Ben
Can you show the SendObject line that works in 2003 now?
Avatar of bfuchs

ASKER

@Scott,

At the moment I'm confused..

Originally it didnt work at my pc either, then you suggested the EditMessageargument and it worked at my pc A2003. (So I got all exsited!!!-:)

Then I tested in A2007 and didnt work.

So I went back to my pc and now it works regardless if I include the EditMessageargument or not..

The acSendNoObject didnt seem to make any difference.

Thanks,
Ben
Avatar of bfuchs

ASKER

Hi Experts,

So where do we stand with this, is there any hope?

Thanks,
Ben
There have been reports of troubles with SendObject after updating Windows 10 (if you're running Windows 10). Can you check the OS versions on your machines?

See this question on EE for links to some other question about the same thing:

https://www.experts-exchange.com/questions/29076790/Can-anyone-tell-me-why-this-code-in-Access-2010-won't-run-and-how-to-fix-it-after-Win10Pro-1709-fall-creators-update.html
Avatar of bfuchs

ASKER

Hi,

We didnt update any OS, only the office version was upgraded to 2016 (as mentioned, all besides Access).
Most of our users have Win7 Pro.

It sounds like the Outlook Automation mentioned in that other post does work here, however its seems like very complicate code..is there any simple alternative?

Thanks,
Ben
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bfuchs

ASKER

Hi Scott,

Finally this seems like what I was waiting..
Just waiting for user to test and confirm.

Thanks,
Ben
Avatar of bfuchs

ASKER

Hi Scott,

This is working fine!

Just one question.
Is it possible to have it open by default as HTML message?
Tried changing .Body to .HTMLBody but that didn't do the trick.

Thanks,
Ben
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bfuchs

ASKER

Thank you very much!!
Avatar of bfuchs

ASKER

Hi,

I need it to have users start typing in HTML format when msg opens up.
see attached1 how it currently looks (included BodyFormat = 2)
And see attached2 how I want it to open.

Thanks,
Ben
Untitled.png
Untitled.png
Avatar of bfuchs

ASKER

Hi,

Of course, it's not much use if you don't actually have any HTML-formatted text ...
Not really, in plain text format you cant play anything with text not even change fonts, make bold etc..
Besides the default format of outlook is HTML when you start new message.
This is probably what gets user's annoyed, when outlook gets open thru Access..

Thanks,
Ben
Hi Ben,

I'd suggest you open a new question for this.
Avatar of bfuchs

ASKER

Hi,

OK I will

Thanks,
Ben