View Single Post
  #6  
Old March 27th 06, 01:06 AM posted to microsoft.public.outlook.program_vba
Hlewis
external usenet poster
 
Posts: 7
Default move to Outlook Folder

I do not have a Move Statement. I looked at the code via the link you sent
and I don't think I'm following you on this. What I am trying to do is based
on a folder selected from a drop down box on an Access form, have Access move
a message from the "Inbox" to the folder selected.

Please keep in mind that I am new to all of this and really could use a
little more explaination than an experience programmer. I don't mean to be a
pain in your rear end, but you are describing things over my head. Believe
my, it does not take much to do that when it comes to writing code.

I don't know if this will help but this is what I have so far. I have
created a module with the following code:

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

Can you briefly tell me what this code is doing. It appears that it is just
calling up the Outlook folder.

If I'm understanding your last response, I need to also have a move command
before this code? This is where I would but the following to specify the
Outlook folder to got to:
Set targetFolder = GetFolder("Mailbox - TLMS Cost")
theItem.Move targetFolder

If so, what would the code look like that would take the results of my
selection from the drop down box? What needs to happen for it to know to
move the email in the form currently visible?
--
Hlewis


"Sue Mosher [MVP-Outlook]" wrote:

You enter it before your Move statement:

Set targetFolder = GetFolder("your Outlook folder path")
theItem.Move targetFolder

where GetFolder() is the sample function I mentioned earlier.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"Hlewis" wrote in message ...
Okay. Where in the code to I enter the path to the folder?
--
Hlewis


"Sue Mosher [MVP-Outlook]" wrote:

Yes, the basic technique of walking the folder hierarchy is the same, regardless of where in the hierarchy the folder may be located.

"Hlewis" wrote in message ...
Sue,
I looked at this and the path appears to be "Mailbox - TLMS Cost/Inbox".
This mailbox is not in a public folder. It is at the same level as my
default mailbox. So would I use this in the sample code you provided? I'm
sorry if I'm asking silly questions but I am still very new to this. Please
be patient with me. :-)
--
Hlewis


"Sue Mosher [MVP-Outlook]" wrote:

To use the Move method, you need a MAPIFolder object for the target folder. To get a non-default folder in another mailbox, walk the folder hierarchy using the Folders collections or use a function that does that for you. See http://www.outlookcode.com/d/code/getfolder.htm


"Hlewis" wrote in message ...
It is visible in my Outlook folder. What would I do next?
--
Hlewis


"Sue Mosher [MVP-Outlook]" wrote:

Only if you have the entire mailbox visible in your Outlook folder list, in other words, only if the mailbox added as a secondary mailbox through your Exchange account settings.


"Hlewis" wrote in message ...
I have an Access DB that links to a shared mailbox in Outlook (linked to the
Inbox). I have query that logs the receipt times of each email coming into
the mailbox. Please note that I the linked mailbox is not my default Inbox.
This DB is linked to shared mailbox on our server. I want to know if it is
possible to create code that will have MS Access move specific emails to
specific folder within this shared mailbox?
I have already created a form that will allow the user to view each email
separately. They will then select a folder to move the email to from a drop
down menu on this form. I want Access to then move the email to this folder
and out of the Inbox within Outlook. If anyone has any idea how to do this I
would love to hear some of your suggestions.
--
Hlewis




Ads