INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

vb6 outlook 2013 automation

vb6 outlook 2013 automation

(OP)
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?

RE: vb6 outlook 2013 automation

(OP)
using Windows 8 running VB6 as admin and compatibility as XP sp3

RE: vb6 outlook 2013 automation

Have you set a reference to the Outlook object library as well as Word?

Beir bua agus beannacht!

RE: vb6 outlook 2013 automation

Also, do you have Option Explicit 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.

RE: vb6 outlook 2013 automation

>..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.

RE: vb6 outlook 2013 automation

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.

RE: vb6 outlook 2013 automation

(OP)
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.


RE: vb6 outlook 2013 automation

"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.

RE: vb6 outlook 2013 automation

(OP)
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.

RE: vb6 outlook 2013 automation

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.

RE: vb6 outlook 2013 automation

(OP)


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. !!

RE: vb6 outlook 2013 automation

(OP)
Fixed my Display as HTML issue, stupid developer issue, however IDE source code fails even though the EXE works.

RE: vb6 outlook 2013 automation

> 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.

RE: vb6 outlook 2013 automation

(OP)
"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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close