Solved

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

Posted on 2011-03-05
7
623 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 68

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 68

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
If you don't know how to downgrade, my instructions below should be helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 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

16 Experts available now in Live!

Get 1:1 Help Now