Solved

Reference Outlook object

Posted on 2013-01-16
6
306 Views
Last Modified: 2013-02-01
I would like to reference a object in Outlook for example the subject line in the task form.  How would I do that?
0
Comment
Question by:Kylo Ren
  • 2
  • 2
  • 2
6 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38786139
Are you using interop?
0
 
LVL 5

Author Comment

by:Kylo Ren
ID: 38786157
No I'm not. Is that what You recommend?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38786217
Given that the question is in .NET zones, I assumed you are interfacing with Outlook from a .NET application. Is that correct?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Accepted Solution

by:
shorvath earned 500 total points
ID: 38787223
Create a Macro in Outlook and paste the following code:

Dim objNameSpace As Outlook.NameSpace
Dim objTASK_Folder As Outlook.MAPIFolder
Dim objTasks As Outlook.Items
Dim objTask As Outlook.TaskItem

Set objNameSpace = Application.GetNamespace("MAPI")
Set objTASK_Folder = objNameSpace.GetDefaultFolder(olFolderTasks)
Set objTasks = objTASK_Folder.Items
Set objTask = Application.CreateItem(olTaskItem)

For Each objTask In objTasks
    MsgBox objTask.Subject
Next

Set objNameSpace = Nothing
Set objTASK_Folder = Nothing
Set objTasks = Nothing
Set objTask = Nothing

Open in new window

0
 
LVL 5

Author Comment

by:Kylo Ren
ID: 38790804
code cruiser, i am working in outlook only but i think outlook supports .net

shorvath, this may be what i am looking for.  i am assuming these lines clears the variables?

Set objNameSpace = Nothing
Set objTASK_Folder = Nothing
Set objTasks = Nothing
Set objTask = Nothing

also, can i import macros into visual studio?
0
 
LVL 9

Expert Comment

by:shorvath
ID: 38793559
it destroys the objects you created... VBA does not have garbage cleanup..

You can do most things using VBA within Outlook including COM and API calls..

You can do everything using Visual Studio and the MS Office Object Library.
    ( sample   ->   http://support.microsoft.com/default.aspx?id=310258)

It really depends on what you are doing..   developing an stand alone app or a simple solution for you Outlook users...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

910 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now