Re: I need to create a Folder Wrapper Class... HELP!!!

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Kristy (kristy_at_fluidsoftware.co.nz)
Date: 06/17/04


Date: 16 Jun 2004 20:51:10 -0700

Hi

Thanks again, you're advice is great and I've learnt a lot but
obviously still have some way to go... Everything makes sense and I
can see how it is all going to work, but I can't figure out how to
instantiate my Items collection. Or if I'm maybe going about it the
wrong way. It makes perfect sense to me with the Explorer and
Inspector since I call an Inithandler for both from the on_connection
event to set up everything I need, eg

Friend Sub InitHandlerExpl(olapp As Outlook.Application, strProgId As
String)
On Error Resume Next

Set objOutlook = olapp 'Declared WithEvents
gstrProgId = strProgId
    
If colExpl.Count >= 1 Then
    Set colExpl = objOutlook.Explorers 'declared with events
    AddExpl objOutlook.ActiveExplorer
    FMMOutlookItemsExpl objOutlook.ActiveExplorer.CurrentFolder
End If

End Sub

I can then use the colExpl_NewExplorer event to add a new explorer to
the collection, eg

Private Sub colExpl_NewExplorer(ByVal Explorer As Outlook.Explorer)
On Error Resume Next

AddExpl Explorer

End Sub

So because I need to handle all accessed folders (not just certain
folders) then I want to set it up in a similar manner, but I can't get
this to work, I want to do something like this...

Friend Sub InitHandlerItems(olapp As Outlook.Application, strProgId As
String)
On Error Resume Next
Set objOutlook = olapp 'Declared WithEvents
    
gstrProgId = strProgId

'This is where I get stuck because I want to use something like
objOutlook.Explorers that will put all folders under one umbrella.

Set colItems = ??????

Everything to do with folders seems to need a specific folder so I
can't use something like... Set colItems = oFolder.Items because
oFolder has to be a specified folder.

My plan was then to use like...

Private Sub colItems_FolderChange(ByVal Folder As Outlook.MAPIFolder)
    On Error Resume Next

    AddToItems Folder
End Sub

Once this is done I can then use m_colItems_ItemAdd(ByVal Item As
Object) to check all added items and do whatever I have to when
certain criteria is met.

Am I on the right track?

Thanks for your patience

Kris

"Ken Slovak - [MVP - Outlook]" <kenslovak@mvps.org> wrote in message news:<eHF8vQ6UEHA.220@TK2MSFTNGP10.phx.gbl>...
> Where you instantiate your items collection is up to you. I usually declare
> the collection as Public in a Globals code module As New Collection. I then
> call the code that adds folders and their Items collection to the wrapper
> collection whenever I want. If I'm only handling certain folders I do it on
> demand. If I'm setting up initially to handle a set of folders I do that in
> the InitHandler code.
>
> If you say wanted to add the folder for any new Explorer I'd call the adder
> code in NewExplorer.
>
> The initialization of the actual class that's put in the wrapper collection
> happens in the adder code:
>
> Public Function AddToItems(oFolder As Outlook.MAPIFolder) As String
> Dim objItemsWrap As New clsItemsWrap
>
> A little clearer?
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> "Kristy" <kristy@fluidsoftware.co.nz> wrote in message
> news:1c6477a7.0406151617.7f69447f@posting.google.com...
> > Hi Ken
> >
> > Thanks for all of that :-)
> >
> > I must be having a real blonde day though becasue I still can't get it
> > to work! I can't get any of the events to fire so I must still have
> > it set up incorrectly. I really cant seem to see the tree for the
> > forest!
> >
> > Some more questions if you please...
> >
> > Obviously my initialisation code isn't working so basically how should
> > I set it up? Do I need to initialise gBaseClassItems in the
> > On_Connection event or should I do something in the Outlook_Startup
> > event? What would the difference be? What would be better and why?
> >
> > ie, should I use the below in the Connect.dsr
> >
> > Private gBaseClassItems As New clsItemsOutAddin
> >
> > Private Sub IDTExtensibility2_OnConnection(ByVal Application As
> > Object, _
> > ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
> > ByVal AddInInst As Object, custom() As Variant)
> >
> > gBaseClassItems.InitHandlerItems Application, AddInInst.ProgId
> >
> > End Sub
> >
> > Then what would I put in the inithandler... AddToItems oFolder maybe?
> >
> > Or maybe mre straightforward like this in the Outlook_Startup event...
> > (would this even work, do I need to get the MapiFolder?)
> >
> > Private Sub objOutlook_Startup()
> >
> > Set m_objFolder = Outlook.ActiveExplorer.CurrentFolder
> >
> > End Sub
> >
> > Thanks Ken, as you can see I'm a bit confused!
> >
> > Kristy



Relevant Pages

  • Re: Move applied to MailItem alters ReceivedTime
    ... Seems to work both as sub or function, but the result is ... > Are you moving messages between two folders from *different* PST stores? ... It appears that after applying the move method the ReceivedTime ... >> Dim found As Boolean ...
    (microsoft.public.outlook.program_vba)
  • Re: Relative File Path Name
    ... provide me with some sample code that uses them. ... Sub SaveInstructions(ProjNum, DocName) ' called by Private Sub cmdOK_Click ... and related destination folders are stored, ...
    (microsoft.public.word.vba.general)
  • Re: Delete/Move Attachments
    ... here is a sample for a recursive iteration through the folders: ... Loop through the Outlook folders hierarchy for handling _ ... Public Sub HandleAllItems ... ' Loop through all folders. ...
    (microsoft.public.outlook.program_vba)
  • Re: execute macro for all documents in the folder
    ... fLog.writeline (oFolderPath) ... > partial to stating how many folders and how many macro's prior, ... >> Sub MacroRunner() ... >> Dim fFolderName As String, mFileName As String, oFolderPath As ...
    (microsoft.public.word.vba.general)
  • Re: Imaging Drivers Slowing Explore/My Computer & Net Explorer Address
    ... Go to your folders where you have photo's and video's stored (sub folders ... Close explorer. ... it had something to do with a conflict with the Scanner Drivers. ...
    (microsoft.public.windowsxp.general)