Solved

Using VB6 to display the Category and Folder of an email in Outlook 2007

Posted on 2011-03-05
7
626 Views
Last Modified: 2012-05-11
We have a code that displays all the emails in Outlook 2007.

We want to also display the folder where its saved and also the category that is assign,

How can we incorporate this in our app?

(Included is part of the code, its in VB6)
Sub ProcessStore(olkFld As Object)
    Const olMailItem = 0
    Const olMail = 43
    Dim olkItm As Object, olkSub As Object, olkAtt As Object
    If olkFld.DefaultItemType = olMailItem Then
        For Each olkItm In olkFld.Items
            If olkItm.Class = olMail Then
                strBuffer = strBuffer & x & " - " & sp _
                          & olkItm.SentOn & sp & olkItm.ReceivedTime & sp & olkItm.SenderName & sp _
                          & olkItm.Subject & sp & olkItm.to & sp & olkItm.Body & vbCrLf
               'Display and export
                List.AddItem strBuffer
                Print #2, strBuffer
                strBuffer = ""
            End If
        Next
    End If
    
    For Each olkSub In olkFld.Folders
        ProcessStore olkSub
    Next
End Sub

Open in new window

0
Comment
Question by:rayluvs
7 Comments
 
LVL 2

Expert Comment

by:active_agent
ID: 35046393
Just to confirm, you are looking to display the folder name and categories associated with the mail item.

- Folder Name : You are already passing the Folder object to ProcessStore, i believe there is Name property to that object.
- Category : Have you tried Categories property of mail item you were displaying.

Let me know how it goes.

Thanks
0
 
LVL 69

Expert Comment

by:Qlemo
ID: 35046420
That is correct. If you want to display the complete path of the folder, you can use .FolderPath.
MailItem.Categories consists of a concatenated String of categories - so there can be more than one categorie in it.
0
 

Author Comment

by:rayluvs
ID: 35046562
Yes , I am looking to display the folder name and categories associated with the mail item.

I tried ".FolderPath' and it gave me

                      Run-time error: '438'  
                      Object doesn't support this property or method

How do I use MailItem.Categories to display the string or categories?
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 250 total points
ID: 35046632
The parent is the folder therefore:
olkItm.parent.folderpath

and for the category string
olkitm.categories

Chris
0
 
LVL 69

Assisted Solution

by:Qlemo
Qlemo earned 250 total points
ID: 35046641
I assume that is not your code? Because we thought you have some experience already, so we haven't been much detailled in our answers.

Chris is correct. You can access the folder path either by
   olkItm.Parent.FolderPath
or, since we also have the folder itself ready,
   olkFld.FolderPath
0
 

Author Comment

by:rayluvs
ID: 35046739
Thanx, worked perfectly!
0
 

Author Closing Comment

by:rayluvs
ID: 35046744
thanx
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

820 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