My email code suddenly doesn't work anymore.

J

Jonathan Brown

All of a sudden this email code doesn't work anymore. I had written it for
an Access 2000 application. The IT department upgraded to MS Office 2003
about close to a month ago, but this code has continued to work up until a
few days ago. I don't know what has happened to cause it to stop working.
We use Outlook with exchange server. Is there anything that could have
changed on the Exchange server to cause this to stop working? I haven't
changed my references either. I still have the Microsoft Outlook 11 Object
Library selected. When I attempt to run the code and it fails, I click debug
and the following line is highlighted yellow:

objMail = objOutlook.CreateItem(olMailItem)

When I mouse over it I get a tooltip that says: objMail = nothing


Here is my code:
------------------------------------------------------------------------------------------------
'Send Email to an FSR

Dim objOutlook As New Outlook.Application
Dim objMail As MailItem

Set objOutlook = New Outlook.Application
Set objMail = objOutlook.CreateItem(olMailItem)

EmailAddr = Me.Email
CopyEmailAddr = ""
Subj = "Information about the FSR Update database."
Body = "tsup dog"

PathName = ""

With objMail
.To = EmailAddr
.cc = CopyEmailAddr
.Subject = Subj
.Body = Body
.NoAging = True
.Display
End With

'****** Send the email without prompts *******
SendKeys "%{s}", True
'****************************************************

Set objMail = Nothing
Set objOutlook = Nothing
-----------------------------------------------------------------------------------------------

When I run it with error handling, it gives me this error:
Run-time error '-2079129597 (84130003)': The operation failed.

Again, this just suddenly stopped working. Any ideas?
 
A

Arvin Meyer [MVP]

You have not dim'd these variables:

EmailAddr
CopyEmailAddr
Subj
Body

That could be a possible cause. Why not just use the for and literal values
directly?
 
J

Jonathan Brown

oops, you're right. In the code snippet below I forgot to include that, but
I had dim'd those variables higher up in my proceedure. And you're also
correct, I could just use the literal values.

Unfortunately, that's not where the code is breaking though. I think it's
dieing at the set objOutlook = New Outlook.Application line.

Here's another thing to consider. I copied the application to my personal
laptop which is not used to connect to our corporate network, nor is it
configured to use MS Exchange. It also happens to have Office 2007 on it.
When I copied it to my personal laptop, the code works no problem.

So now, I'm thinking that there's something going on with Outlook 2003, or
Exchange Server. Doing a Google search for that run-time error message I'm
getting brings up a lot of threads from people who are having a lot of weird
issues.

Anyway, let me know if you come up with any other ideas.
 
J

Jonathan Brown

It's fixed!!!! Okay, allow me to explain the situation. As I had mentinoed in
one of my previous posts, I have to connect to our corporate network through
Citrix. The IT department recently upgraded the version of Microsoft Office
on the Citrix servers to MS Office 2003.

The computers that all of my managers are using are still using Office 2000.

When I connect to the network through Citrix and go into my application to
do anything, the Microsoft Outlook 9.0 Object Library reference gets replaced
with the Microsoft Outlook 11.0 Object Library. When that happens, all of the
computers that are still using Office 2000 stop working since they can't find
the Microsoft Outlook 11.0 Object library.

So what I had to do was login through Citrix, then use Remote Desktop
Connection to remote control on of my manager's computers and then open the
application and fix the references.

Now, Is there a way to have both references in there? Could I have the
Microsoft Outlook 9.0, 10.0, 11.0, and 12.0 libraries in there so that it'll
work no matter what version of Office is running?
 
T

Tony Toews [MVP]

Jonathan Brown said:
Now, Is there a way to have both references in there? Could I have the
Microsoft Outlook 9.0, 10.0, 11.0, and 12.0 libraries in there so that it'll
work no matter what version of Office is running?

Better yet have no references at all to Outlook. Use late binding.

Late binding means you can safely remove the reference and only have
an error when the app executes lines of code in question. Rather than
erroring out while starting up the app and not allowing the users in
the app at all. Or when hitting a mid, left or trim function call.

This also is very useful when you don't know version of the external
application will reside on the target system. Or if your organization
is in the middle of moving from one version to another.

For more information including additional text and some detailed links
see the "Late Binding in Microsoft Access" page at
http://www.granite.ab.ca/access/latebinding.htm

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top