Solved

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

Posted on 2011-03-05
7
624 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
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Outlook - slow response (Exchange 2013) 7 44
Way to Disable Outlook Follow Up Flags 3 34
exchange out of office 8 39
Batch/VBScript : Disable Windows tasks 7 23
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
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…
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…
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…

911 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

22 Experts available now in Live!

Get 1:1 Help Now