
Signature
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
Dmitry,
Thank you for you help so far, I am sure that we are close. This is what I
have:
Sub Paul()
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 objFolder =
objNS.GetDefaultFolder(olFolderInbox).Folders("Projects").Folders("City of
Peoria").Folders("193648 - Happy Valley Road")
'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
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Copy objFolder
End If
End If
Next
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub
What it does is it placees a copy in the inbox. There is nothing obvious to
me, but maybe you or someone else could help determine why it is not going to
Set Folder.
Thanks
> Mailbox\Inbox\Projects\City 1\Project 1:
> set Folder =
[quoted text clipped - 58 lines]
> >> >
> >> > Frustrated
Dmitry Streblechenko - 23 May 2008 06:13 GMT
MailItem.Copy does not take any parameters (folder or anything else). It
simply creates and returns the new item created in (you guessed it) the
Inbox folder:
set objNewItem = objItem.Copy
objNewItem.MoveTo objFolder

Signature
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
> Dmitry,
>
[quoted text clipped - 112 lines]
>> >> >
>> >> > Frustrated
Paul - 23 May 2008 15:31 GMT
Thanks for the help...I am still stumped and really wish Outlook had a
recorder. I understand your note and made the following changes of adding
your statements to the if loop. What I get now are two copies in my
in-basket....if you could help me with the missing link it would be great.
And my next step is to take this same message and move it to the public
folder down below. So in short I want to take the message in my in-box and
have it placed into moved/copied into two folders and not be in my inbox
(copy base message to folder 1, move message from inbox to folder 2)
Thanks in advance
Sub Paul()
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 objFolder =
objNS.GetDefaultFolder(olFolderInbox).Folders("Projects").Folders("City of
Peoria").Folders("193648 - Happy Valley Road")
'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
For Each objItem In Application.ActiveExplorer.Selection
If objFolder.DefaultItemType = olMailItem Then
If objItem.Class = olMail Then
objItem.Copy
Set objNewItem = objItem.Copy
objNewItem.MoveTo objFolder
End If
End If
Next
Set objItem = Nothing
Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End Sub
> MailItem.Copy does not take any parameters (folder or anything else). It
> simply creates and returns the new item created in (you guessed it) the
[quoted text clipped - 119 lines]
> >> >> >
> >> >> > Frustrated
Dmitry Streblechenko - 23 May 2008 17:58 GMT
Why are you calling Copy twice?

Signature
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
> Thanks for the help...I am still stumped and really wish Outlook had a
> recorder. I understand your note and made the following changes of adding
[quoted text clipped - 180 lines]
>> >> >> >
>> >> >> > Frustrated