Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Outlook folders export: how to pick the fields (properties) name with VBA.

Posted on 2009-04-08
7
Medium Priority
?
401 Views
Last Modified: 2013-11-27
I am looking for a VBA code that allows me to list every field name of my Outlook messages.
In other words, I want to know the name of the mapped fields I usually can get with the Outlook export action to .xls file; I would then use them in MS Access functions like below.
Thank you.
Dim olkItems As Object, olkItem As Object
....
For Each olkItem In olkItems
...=olkItem.Field1 (es. Name)
...=olkItem.Field2 (es. Subject)
...=....
Next olkItem

Open in new window

0
Comment
Question by:Sar1973
[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
7 Comments
 
LVL 28

Expert Comment

by:TextReport
ID: 24101351
Once you have your outlook message variable you can use the code below to loop through all the properties, either as a count or directly as objects
Cheers, Andrew
Dim cnt As Long
For cnt = 0 To outMessage.ItemProperties.Count - 1
    Debug.Print outMessage.ItemProperties(cnt).Name
Next cnt
 
Dim oip As Outlook.ItemProperty
Dim oips As Outlook.ItemProperties
Set oips = outMessage.ItemProperties
For Each oip In oips
    Debug.Print oip.Name
Next oip

Open in new window

0
 
LVL 9

Author Comment

by:Sar1973
ID: 24105779
If I launch this code, I get some errors: outMessage is not delcared, so I get "an object is necessary"
If I declare it as object, I get "With variabloe not set"
0
 
LVL 28

Expert Comment

by:TextReport
ID: 24105805
outMessage is my variable that is either an Object or Outlook.MailItem
I think with late binding, dimming the variable as Object, then you will need to use the For cnt looping
Cheers, Andrew
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 9

Author Comment

by:Sar1973
ID: 24107357
Then, could you please provide a code that works and gives me every field name?
0
 
LVL 28

Expert Comment

by:TextReport
ID: 24107385
Have you got the code that give you an Outlook message, either the message you have created or the message you have found. If so can you please provide what you have.
Cheers, Andrew
0
 
LVL 9

Author Comment

by:Sar1973
ID: 24107523
I got it: if you use this code you get a string with every property and field name.
I gues it would work also if you pick a single item of an Outlook folder instead of creating a new item/message and looking what it's made of.
Dim olkName As String
Dim oip As Outlook.ItemProperty
Dim oips As Outlook.ItemProperties
Dim olApp As Object
Dim oItem As Object
 
Set olApp = CreateObject("Outlook.application")
Set oItem = olApp.CreateItem(0)
Set oips = oItem.ItemProperties
 
For Each oip In oips
    olkName = olkName & ", " & oip.Name
Next
 
Me.Pinco = olkName

Open in new window

0
 
LVL 28

Accepted Solution

by:
TextReport earned 1000 total points
ID: 24108419
Sounds right to me.
With message items you may want to investigate the FIND method to find the messages in your folderthat match certain criteria.
Cheers, Andrew
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

721 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