View Single Post
  #3  
Old January 15th 08, 11:54 PM posted to microsoft.public.outlook.program_vba
paul
external usenet poster
 
Posts: 197
Default Macro for Moving and Copying Mail

Sue,

Your help was great, but I cannot make it work. I am sure it is a
formatting issue. The folder I want to get to a

Inbox\Projects\City of Peoria\193648 - Happy Valley Road\Construction

and

Public Folder\All Public Folder\Phoenix\Transportation\Job\193648 - Happy
Valley

I am not even sure I have the correct divider (/ vs \) or if the space is
creating a problem....

This should not be this hard
Thanks for being there for all of us.




"Sue Mosher [MVP-Outlook]" wrote:

If it's a subfolder of the Inbox, then it's a member of the Inbox's Folders collection:

Set objFolder = objInbox.Folders("Miscellaneous")

To get a non-default folder, you need to 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 and, especially for public folders, http://www.outlookcode.com/codedetail.aspx?id=1164

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Paul" wrote in message ...
Hello,

I need to be able to select a message and have a copy go to one folder and
the original be moved to a second folder. One of these folders is in the
tree under the inbox the other is not. I found the following example that
someone else posted. I cannot get it to recognize the subfolder (HELP ME
HERE) spot. I have tried every formatting option I can think of. Assuming
the folder name is Miscellaneous, what should it look like in that variable
definition?

Second, how can I add a second part to copy it to the folder which is not in
the inbox tree?

Thank you so very very much!!!!

Sub HVR_Const()

On Error Resume Next

Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace, objItem As Outlook.MailItem

Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Parent.Folders(HELP ME HERE)
'Assume this is a mail folder

If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If

If Application.ActiveExplorer.Selection.Count = 0 Then
'Require that this procedure be called only when a message is selected
Exit Sub
End If


Ads