Outlook Email from MS Access, a new one.

TJBernard

Registered User.
Local time
Today, 07:13
Joined
Mar 28, 2002
Messages
176
:)

Sorry, I have a new question for the MS Access open up an Outlook E-Mail experts. So I decided to start a new thread.

I have an MS Access database, that in the past opened up and created a new Outlook e-mail message just fine.

All of a sudden it quit working. I believe it was the move to Windows XP with Office 2003.

The problem is, I cannot track down what is causing the error, because it is so early in the code, and in such an odd location.

Here is all as far as the code gets...

----------------------------------------------

Dim OLookApp As Outlook.Application
Dim OLookMail As MailItem

Set OLookMail = OLookApp.CreateItem(olMailItem)

-------------------------------------------------

Simple stuff. It compiles just fine, and then when I try to run the code I get the error on the last line (3rd line) that says...

Run-time Error '91'

Object or With block variable not set.

-----------------------------

What in the world? The object is BEING set, and there is no with block variable.

Very strange. If anyone has any ideas let me know.

I will continue to search the net, and if I come across anything, I will add it here.

Thank you for your time!
 
First thing that comes to mind is references. Check your Outlook reference.
 
pbaldy said:
First thing that comes to mind is references. Check your Outlook reference.

I have the reference...

"Microsoft Outlook 11.0 Object Library" selected.

Before I selected this reference, the two objected I "dimed" gave an error.

The other references I have are...

Visual Basic For Applications
Microsoft Access 11.0 Object Library
OLE Automation
Microsoft DAO 3.6 Object Libary
Microsoft Active X Data Objects 2.1 Library
Microsoft Visual Basic For Applications Extensibility 5.3

And then last the Outlook reference.

This is so strange, for it to quit working.
 
Maybe it's just not shown, but have you set OLookApp? Here's some working code of mine (relevant bits):

Code:
  Dim MyOutlook        As Outlook.Application
  Dim MyMail           As Outlook.MailItem

  Set MyOutlook = New Outlook.Application
  Set MyMail = MyOutlook.CreateItem(olMailItem)
 
Since you're setting early binding, why don't you skip the CreateObject part and try this instead:

Code:
Dim OLookApp As Outlook.Application
Dim OLookMail As MailItem

Set OLookMail = New MailItem
 
pbaldy said:
Maybe it's just not shown, but have you set OLookApp? Here's some working code of mine (relevant bits):

Code:
  Dim MyOutlook        As Outlook.Application
  Dim MyMail           As Outlook.MailItem

  Set MyOutlook = New Outlook.Application
  Set MyMail = MyOutlook.CreateItem(olMailItem)

Thank you very much for your help.

This code compiles, but I get a smilar error. In the same location (this time the Set MyMail = MyOutlook.CreateItem(olMailItem) line).

The error is...

Run-time Error 424

Object Required.

Shoot, I will keep searching, thank you!
 
boblarson said:
Since you're setting early binding, why don't you skip the CreateObject part and try this instead:

Code:
Dim OLookApp As Outlook.Application
Dim OLookMail As MailItem

Set OLookMail = New MailItem

Thank you very much for your time.

This code would not compile for me.

Darn.
 
Thank you very much for your help.

I beleive I have found a fix around the error.

If so, I will come back and share.

Thank you!
 
Thank you everyone.

The code given to me be pbaldy did work correctly.

I made a type (ugh, Fridays) and finally found it after walking away from my machine.

Thank you everyone for your help!
 
I'm bringing this tread back from the "dead".

My system: Vista (...) with access 2000.

I'm trying to create a new Outlook message from access, and get this errormessage: "Compile error: User-defines type not defined".

The code:
PHP:
Dim OLookApp As Outlook.Application
Dim OLookMail As MailItem

Set OLookMail = New MailItem

pbaldy writes "First thing that comes to mind is references. Check your Outlook reference." How do I check my references...
 
ref1.png
 
Thanks

Just so you guys know - Thanks for this thread it has been really helpful

Cheers

Smudger
 
Try this

Try adding the word "New" like this (works on occasion for me when I can't figure out a run-time error):

Dim OLookApp as New Outlook.Application
Dim OLookMail as MailItem

Set OLookMail = OLookApp.CreateItem(olMailItem)
 

Users who are viewing this thread

Back
Top Bottom