Solved

Convert my email definitions to late binding

Posted on 2004-09-13
9
539 Views
Last Modified: 2012-05-05
Can someone convert this to late binding?

Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Set myolApp = CreateObject("Outlook.Application")
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderDrafts)
0
Comment
Question by:kbutler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 2

Expert Comment

by:PendragonZero
ID: 12051434
I think using CreateObject("Outlook.Application") is late binding.
And early binding would be:
Set myolApp = New Outlook.Application
of course you need the reference to the Outlook Library where as in late binding you do not
Pen
0
 

Author Comment

by:kbutler
ID: 12051490
Acually I have late binding on some of my email procedures but the procedure that I took this code from needs to get into the Drafts forlder.
So the real problem here is the myNamespace and myFolder statements.
0
 
LVL 34

Expert Comment

by:flavo
ID: 12051523
Dim myolApp As object
Dim myNamespace As object
Dim myFolder As object
Set myolApp = CreateObject("Outlook.Application")
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderDrafts)


Done.

test be removing your refrence the  MS Outlook Obj Library.

Dave
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 34

Expert Comment

by:flavo
ID: 12051528
i dont have outlook, so im not sure what value this is.. before you remove Outllok from your refrences in the debug window (intermediate window) type

?olFolderDrafts

and see what its value is, replace olFolderDrafts with this value
0
 
LVL 2

Accepted Solution

by:
PendragonZero earned 500 total points
ID: 12051535
btw, using late binding, you cant use Outlook constants like olFolderDrafts
i think olFolderDrafts = 16

so try flavo's code with
Set myFolder = myNamespace.GetDefaultFolder(16)

0
 
LVL 2

Expert Comment

by:PendragonZero
ID: 12051539
i need to learn to type faster... lol
0
 
LVL 34

Expert Comment

by:flavo
ID: 12051552
Didnt have Outlook (and actually never used it) so i didnt know the value.
0
 

Author Comment

by:kbutler
ID: 12051563
PendragonZero
16 is the answer. Where do you get a listing of the other numbers?

And thanks for the answer, I tested it.
0
 
LVL 34

Expert Comment

by:flavo
ID: 12051566
in the intermeditae window just type ?Const

it will return the value (as long as its refrenced)

to open the intermediate window, while in VBA, press ctrl+g

Dave
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question