Solved

Outlook Set Mapifolder to a string?  How do I do that?

Posted on 2003-12-05
1
515 Views
Last Modified: 2010-05-01
I have some code that I want to cycle through a certain Inbox and save the Attachments.  This Inbox may change but I do know the path..

"\\Mailbox - 3114 Test\Inbox"  one time
"\\Mailbox - 3115 Test\Inbox" next ...
       
        Dim myOlapp As Outlook.Application
        Dim myoMsg As Outlook.MailItem
        Dim myOFolder As Outlook.MAPIFolder
     
        myOlapp = CreateObject("Outlook.Application")
        myoMsg = myOlapp.CreateItem(Outlook.OlItemType.olMailItem)
 --     myOFolder  = "\\Mailbox - 3114 Westin\Inbox" -----

Here is where I get an error?  How do I set the folder to this string?

Thanks,

Rog
0
Comment
Question by:Rog
1 Comment
 
LVL 44

Accepted Solution

by:
bruintje earned 125 total points
ID: 9884797
there is a good sample here

source : http://www.slipstick.com/dev/code/getfolder.htm

Public Function GetFolder(strFolderPath As String)As MAPIFolder

  ' folder path needs to be something like

  '   "Public Folders\All Public Folders\Company\Sales"

  Dim objApp As Outlook.Application
  Dim objNS As Outlook.NameSpace
  Dim colFolders As Outlook.Folders
  Dim objFolder As Outlook.MAPIFolder
  Dim arrFolders() As String
  Dim I As Long

  On Error Resume Next

  strFolderPath = Replace(strFolderPath, "/", "\")
  arrFolders() = Split(strFolderPath, "\")

  Set objApp = CreateObject("Outlook.Application")
  Set objNS = objApp.GetNamespace("MAPI")
  Set objFolder = objNS.Folders.Item(arrFolders(0))

  If Not objFolder Is Nothing Then
    For I = 1 To UBound(arrFolders)
      Set colFolders = objFolder.Folders
      Set objFolder = Nothing
      Set objFolder = colFolders.Item(arrFolders(I))
      If objFolder Is Nothing Then
        Exit For
      End If
    Next
  End If

  Set GetFolder = objFolder
  Set colFolders = Nothing
  Set objNS = Nothing
  Set objApp = Nothing
End Function

hope this helps a bit
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

Suggested Solutions

Title # Comments Views Activity
Mysql vs Oracle 10 120
VBA Check for Character 9 72
Windows 10 start screen issues 9 47
Protecting vb6 & .Net code Obfuscation 18 55
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

759 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

21 Experts available now in Live!

Get 1:1 Help Now