Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb6 outlook 2013 automation

Status
Not open for further replies.

jgo333n

Programmer
Jul 16, 2007
27
GB
This is not difficult to do, but I am getting ActiveX Component Can't create object when I try to create an object. I have added a reference to Microsoft Word 15 Object Library.
and here is the code:

Dim objOutlookApp As Outlook.Application
Dim objNameSpace As Outlook.NameSpace
Dim objMail As Outlook.MailItem

'Set the application objects
Set objOutlookApp = GetObject("", "Outlook.Application")

If objOutlookApp Is Nothing Then
Set objOutlookApp = New Outlook.Application
Set objNameSpace = objOutlookApp.GetNamespace("MAPI")
End If

The error occurs on this line - Set objOutlookApp = GetObject("", "Outlook.application")

Intelligence works so the IDE is recognizing the objects.

Can anyone help and if not, anyone know The A Teams phone number?
 
using Windows 8 running VB6 as admin and compatibility as XP sp3
 
Have you set a reference to the Outlook object library as well as Word?

Beir bua agus beannacht!
 
Also, do you have [tt]Option Explicit[/tt] at the top of your code?
And what error - if any - you get when you run it with full compile (Ctrl-F5)?

If "Intelligence works so the IDE is recognizing the [Outlook?] objects. " than why do you need this line:
Set objOutlookApp = GetObject("", "Outlook.application")

You already set it to Outlook with:
Dim objOutlookApp As Outlook.Application


Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
>..than why do you need this line:
Set objOutlookApp = GetObject("", "Outlook.application")

However if you are or want to use late binding GetObject will only do the biz if an instance of Outlook is already running, if not I think you'll need to use CreateObject.
 
I'm not sure what you hope to get by setting funky appcompat settings at random like this (XP SP3? Wha?). You already probably lack a UAC awareness manifest, so Windows already assumes you're a legacy program.

Is this on your development machine? Does the machine even have Office 15 (2013) installed? And even so, why are you trying to use early binding, it's a sucker's game.


Getobject() is used to connect to an existing running instance of an OLE Automation application, it doesn't "creat an object" in the usual sense.

See GetObject and CreateObject behavior of Office automation servers, which may answer your question.
 
The source code is good as it works with other editions off outlook, the PC is a dev box.

It appears that outlook 2013 does not ship with all the older dlls required to allow vb6 to automate sending emails.

I am experimenting further.


 
to allow vb6 to automate sending emails."

You do not need to have outlook installed in order to send an e-mail from VB6 application. Look up CDO, there is my post here somewhere on TT with the code.

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
I know but my company want to do it this way.

However I think they are going to have to change their minds.

I will look up your thread on CDO for tomorrow.
 
Your symptoms don't seem to have anything to do with "older DLLs." You said you couldn't even get connected to an instance of Outlook.

For that matter, Outlook 2013 still supports MAPI as far as I can tell: Outlook 2013 MAPI Reference.

But what you have here isn't any kind of VB6 issue, but an Office (Outlook) issue. You'd see the same thing if you were writing in VBScript, C++, etc. So this question is in the wrong forum.
 


When I build the application the EXE behaves itself and sends an email but running in the IDE it fails.

A secondary issue is now I need to get outlook 2013 to display html. and following the instructions to 'Display as HTML' does not work. !!
 
Fixed my Display as HTML issue, stupid developer issue, however IDE source code fails even though the EXE works.
 
> however IDE source code fails even though the EXE works
This could be because you are running the vb6 IDE elevated (as you should) but Outlook has been launched un-elevated (as it normally is). The exe will normally be run un-elevated of course.
Given the foregoing I expect the exe will fail too if it is run elevated; if you never intend to run the exe elevated this is not a an issue.
I have experienced similar behaviour when 'automating' Outlook via the MSMAPI32.OCX.
 
ActiveX Component Can't Create Object" error when trying to create an outlook object in IDE is resolved by turning of the compatibility mode, for the VB6 ide. Once this is done all works as it should, and the source code behaves as per the exe does.

So thank you everyone this issue is now resolved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top