Email via Outlook (1 Viewer)

yeowkev19

New member
Local time
Today, 15:26
Joined
Dec 21, 2019
Messages
7
Hello Everyone!

Hope all is well!
I have this attached code which works in MS Access 2016 on my laptop.
I applied the same code to the MS Access 2007 version and I got this error!
Can anyone help please?

Thanks

Best regards
kevin
 

Attachments

  • 2019-12-21.jpg
    2019-12-21.jpg
    101.2 KB · Views: 84

vba_php

Forum Troll
Local time
Today, 17:26
Joined
Oct 6, 2019
Messages
2,880
Hello Everyone!

Hope all is well!
I have this attached code which works in MS Access 2016 on my laptop.
I applied the same code to the MS Access 2007 version and I got this error!
Can anyone help please?

Thanks

Best regards
kevin
there's a couple of things to say here regarding your post yeo. First of all, you should have posted this in a category here:

https://www.access-programmers.co.uk/forums/forumdisplay.php?f=3

but one of the moderators will move it for you. 2nd => you should know that outlook has a terrible reputation of being unreliable in almost every aspect of its operation from version 2007 to 2016. I've run into numerous errors and mishaps that make absolutely no sense in every version from 07 to 16, from vba code throwing errors to mail synching to the wrong folders between gmail and outlook, to mail being downloaded randomly and from literally years in the past when it's not even present on the source server anymore! so i'm not at all surprised you're getting an error. but do you realize that you've only posted an image with the yellow line that is given by the VBA editor when an error occurs? It would help a great deal if you posted an image with the actual dialog box that pops up when the code ceases to run and the error is thrown. that box states the error message.
 

yeowkev19

New member
Local time
Today, 15:26
Joined
Dec 21, 2019
Messages
7
Hi !

Thanks for your prompt response!
I have attached the error dialog box as per your request.
Appreciate your support.
Thanks once again
 

Attachments

  • 2019-12-21 (1).jpg
    2019-12-21 (1).jpg
    93.3 KB · Views: 66

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:26
Joined
Feb 28, 2001
Messages
27,442
Kevin, it is always hard to be sure when working with minimal data and when working from a distance that makes hands-on work questionable at best. However, I believe I know the problem. I will explain what I think is wrong, then tell you a simple test to verify whether I am guessing reasonably. Bear with me.

I think your problem is references. You created this app under a newer version of Access but then tried to run it on an older version of Access. (Which generally implies newer or older versions of Office as well.)

Typically, that isn't the way people develop things. They start from the old version and work towards the newer version when it is released. Access supports this automatically because if you have an app with old library references, it will automatically upgrade the app references when you upgrade Access. Therefore, if you had built that under Ac2007 and then tried to run it under Ac2016, it very likely would have worked!

The catch here is that you went backwards, and there is where the speed bump lies. Access doesn't automatically downgrade the references. You have to do that manually. So if you go to a code page and then open Tools >> References, you would probably see a lot of "MISSING" references. (I.e. they have the word MISSING tacked on to the end of the line.) They will be checked but Access can't find them.

That inability to find them is that one or more references have probably changed names between Ac2007 and Ac2016.

So in that dialog box for reference management, find each case of a missing reference. Browse for a library with the same name prefix but a lower number. Check the box for the lower-numbered equivalent to the library that was missing.
 

yeowkev19

New member
Local time
Today, 15:26
Joined
Dec 21, 2019
Messages
7
Hi Mr Docman!

Thanks for your prompt response. I checked the references as told by you but I did not come across any files with the word "missing" even though it was checked or unchecked.
Please see attached file.

I developed the application with Access 2016 but unfortunately the server side of the company is still stuck with Access 2007 and I cannot do anything about it at this juncture.

Thanks

Best regards
kevin
 

Attachments

  • 2019-12-21 (2).jpg
    2019-12-21 (2).jpg
    99.8 KB · Views: 67

NauticalGent

Ignore List Poster Boy
Local time
Today, 18:26
Joined
Apr 27, 2015
Messages
6,428
Good morning Kevin,

I have had this problem in the past as well. I was able to generate an Outlook email from Access and send it without any interaction with Outlook - as long as I was using my home computer.

I would take the code to work and it would choke at the same spot: "Recipients.Add". After many hours of google searching, Forum posting and finally IT support from my company, I finally got in touch with a knowledgeable IT person who informed me that the issue was with Office and Network security settings. Due to viruses and other issues, they chose to disable certain automation features such as adding/removing addressees and sending.

I tried in vain to get them to make an exception in my case but they would not move.

Have a look at the Redemption method. I have a Developers Reference that has a chapter or two on how to use Redemption but I cannot find it at the moment.

For the record, I was unable to use Redemption for the same reasons but your IT folks may have been a little less stringent.

I was however able to emulate the Recipients.Add issue by simply making the "To" line a String and them adding to it.
 

yeowkev19

New member
Local time
Today, 15:26
Joined
Dec 21, 2019
Messages
7
Thanks Pristine for your reply.
I tried to use the To string but it did not work.
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:26
Joined
Sep 21, 2011
Messages
14,576
As a user of 2007, I have the same code as you, albeit on a home computer.

In my references, Outlook library is before the Access Database library.?
I also use actual names not email addresses, so if their email address changes, I do not need to amend code.?
You could try that.
Also try Late Binding?

Clutching at straws I know, but that is all I can offer, sorry. :(
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 18:26
Joined
Apr 27, 2015
Messages
6,428
Actually Kevin,

I have a short video from one of our members that will help. After I was through banging my head, I found this and I use his code on all my applications when I have to include emails.

https://youtu.be/mWf-FExqGr8

Enjoy...
 

isladogs

MVP / VIP
Local time
Today, 23:26
Joined
Jan 14, 2017
Messages
18,291
Kevin
If you are still having trouble and want to try a different approach, you can send email direct from Access without using Outlook. In fact it doesn't even need to be installed.
The alternative approach uses CDO (Collaborative Data Objects) and you can try it using my CDO Email Tester example app.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 15:26
Joined
Aug 30, 2003
Messages
36,139
FYI I moved this thread out of the introductions forum.
 

yeowkev19

New member
Local time
Today, 15:26
Joined
Dec 21, 2019
Messages
7
Hi All!

Thanks for your support and assistance!

I have tried another set of simple codes and it worked fine again on my laptop but still does not work using the Access 2007.
I used the late binding codes learned from a video.
I have the error as attached files.
Anyone knows how to fix this? Kindly advise.

Thanks

Best regards
kevin
 

Attachments

  • 2019-12-22 (1).jpg
    2019-12-22 (1).jpg
    98.8 KB · Views: 60
  • 2019-12-22.jpg
    2019-12-22.jpg
    94.7 KB · Views: 57

Gasman

Enthusiastic Amateur
Local time
Today, 23:26
Joined
Sep 21, 2011
Messages
14,576
Have you tried Access 2007 on another computer.?
 

yeowkev19

New member
Local time
Today, 15:26
Joined
Dec 21, 2019
Messages
7
Hi Gasman

I am actually using this Access 2007 in another computer.
 

Gasman

Enthusiastic Amateur
Local time
Today, 23:26
Joined
Sep 21, 2011
Messages
14,576
No, I mean another computer to the one you are currently testing on that also has 2007.

If you want upload a stripped down version, I'll try it with my Access 2007?

Have you tried a Decompile or a Compact & Repair.?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 17:26
Joined
Feb 28, 2001
Messages
27,442
If you have no missing references, then I am a bit confused about how this works. So I am going to ask a question that might sound strange, You say that this works on Ac2016 but does not work on Ac2007, BUT you mention something about the server being on 2007.

Remembering that references are actually a REGISTRY function and that it is possible for the same app to have errors on one machine but not another one, verify for me that:

When you say "running on an Ac2007" you mean that the front end of the app is running on a machine with Office 2007 installed.

When you say "running on an Ac2016" you mean that the front end of the app is running on a machine with Office 2016 installed.

When you say something about running on a 2007 server, you mean that the front end of the app is running on a machine set up as a server and that it is running with Office 2007 installed.

And verify that at NO time are you running with an Access 2007 installed separately on a machine with Office 2016 installed. Because it is possible to have Office Home, which DOES NOT INCLUDE a version of Access, which in turn means you have to manually install Access separately.

I'm trying to eliminate mixed-environment cases because they have been known to be troublesome. So if this sounds a little pedantic, it is only to be sure of the environment before we go completely crazy here.

I also would like to suggest that you look at Gasman's suggestion of DECOMPILE, which is a command-line function. If you decompile the app, then go in manually and use the toolbar's Debug >> Compile option, that forces ALL CODE to be recompiled. At that point, if you have corruption or a missing reference that isn't so obviously missing, it will show up. If so, it will point to an immediate solution.

Here is a link on the topic: https://www.fmsinc.com/MicrosoftAccess/Performance/Decompile.asp

FMS is a good source for some documentation when you do a web search for a topic and their name comes up in response. So don't be too afraid of them. At worst, they'll have a little bit of self-advertising.
 

Users who are viewing this thread

Top Bottom