Moving outlook explorer selection.

Nishikawa

Registered User.
Local time
Today, 12:30
Joined
May 17, 2007
Messages
97
Hi,

I am trying to do multiple updates in the "Categories" field column in the outlook 2003 using MS access.

The code that I created in VBA works fine only for the first email that is currently highlighted(or selected) on the explorer.

Is that anyway I can make the selection move down using VBA rather than me having to click on the email in the explorer view?

Thanks in advance!!
 
Hey I will try to help you. But Maybe you might need to show your code first.

First where is "Categories"

second It sounds like you have got one mail item. You need however to get the mail items as a collection and then loop through them all.
 
My code is to extract the email subject into MS access and allow users to tag that email via MS Access. MS Access will then transfer the tag into outlook without the user switching between outlook and access.

The problem is that VBA will not overwrite/update the categories field (it is a column if you are looking at the reading pane. This column can be found under field chooser) unless that mail is hightlighted and if the user is to switch between outlook and MS access. It beats the purpose of my code.

Below is the update code. I have been reading around forums and MSDN for the last few days but to no avail.

Code:
Dim oApp As Outlook.Application
Dim oNameSpace As Object
Dim oFolder As Outlook.MAPIFolder
Dim oFind As Outlook.MailItem
Dim oMailItem As Outlook.Items
Set oApp = New Outlook.Application
Set oNameSpace = oApp.GetNamespace("MAPI")
Set oFolder = oNameSpace.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("Finance").Folders("AP")
Set oMailItem = oFolder.Items
EmailCounter = oMailItem.Count
           
'100 Emails limit
For EmailCounter = 1 To 100
    
    'Check if each email has any attachment
    'If oMailItem(EmailCounter).Attachments.Count > 0 Then
        If oMailItem(EmailCounter).Subject = "payment" Then
            If oMailItem(EmailCounter).ReceivedTime = EmailTimeStamp Then
                oMailItem(EmailCounter).Categories = "testing"
            oMailItem(EmailCounter).Save
                
                Exit Sub
            Else
            End If
        Else
        End If
    'End If
            
Next EmailCounter
 

End Sub
 
Hi, I am not sure your code would work, at least I could not get it to. You had no connection between your folder and each email.

Code:
[COLOR=Red]Dim oItems As Outlook.Items    'I think you need this[/COLOR]
Dim oApp As Outlook.Application
Dim oNameSpace As Object
Dim oFolder As Outlook.MAPIFolder
Dim oFind As Outlook.MailItem
Dim oMailItem As Outlook.Items
Set oApp = New Outlook.Application
Set oNameSpace = oApp.GetNamespace("MAPI")
Set oFolder = oNameSpace.GetDefaultFolder([COLOR=Green]olFolderInbox[/COLOR])  'I do not have your folders but what happens if this folder is not there
[COLOR=Red]Set oItems = oFolder.Items  'You need the items from the folder
EmailCounter = oItems.Count  'you need the count of the items[/COLOR]
           
'100 Emails limit
For EmailCounter = 1 To [COLOR=Red]oItems.Count[/COLOR]
    'Check if each email has any attachment
    'If oMailItem(EmailCounter).Attachments.Count > 0 Then
        If [COLOR=Red]oItems.Item[/COLOR](EmailCounter).Subject = "payment" Then
            If [COLOR=Red]oItems.Item[/COLOR](EmailCounter).ReceivedTime = EmailTimeStamp Then
                [COLOR=Red]oItems.Item[/COLOR](EmailCounter).Categories = "testing"
            [COLOR=Red]oItems.Item[/COLOR](EmailCounter).Save
                
                Exit Sub
            Else
            End If
        Else
        End If
    'End If
            
Next EmailCounter
I would make sure that this folder you are using can only have emails in it.

This certainly adds the Category "testing" to the Item. Your problem is now to get outlook to show your customised catergory. You might need to add your category to the master list.

Then you will have to set up outlook properly which is beyond me but this should help
http://office.microsoft.com/en-us/outlook/results.aspx?qu=category&av=ZOL110

Once you have your categories in the list and showing on your reading pain if you go to View - arrange by and then arrange by categories then it will do what you want.
 
It did not really work, I used the below code with my outlook codes to make it work:

SendKeys "{ESC}", True
SendKeys "{ESC}", True
SendKeys "{ESC}", True
SendKeys "{PGUP}", True
SendKeys "{PGUP}", True
SendKeys "{PGUP}", True
SendKeys "{PGUP}", True
SendKeys "{PGUP}", True
'AppActivate "Microsoft Access"
 

Users who are viewing this thread

Back
Top Bottom