R
RosH
Hi all,
I am trying to classify my mails into folders automatically when it
arrives, I have used the run a script rule to achieve it. Whenever a
message arrives, I want the following to happen.
1) Make a folder with the name same as the subject within the personal
folder and not as subfolder in inbox
2) Move the mail to the new folder
With the help of my friends on this group, I was able to make up the
following code which unfortunately does not do the second part. Can
somone help me to kick the macro on the back.
I have tried the following
olMail.Move myFolder.Parent.myDestFolder
olMail.Move myDestFolder
olMail.Move Parent.myDestFolder
------------------------------------------------------------------------------
Sub AutomatingClassification(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
'Dim myFolder As Outlook.Folders
'Dim myDestFolder As Outlook.Folders
strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(strID)
' MsgBox olMail.Subject
Set myFolder = olNS.GetDefaultFolder(olFolderInbox)
FolderName1 = olMail.Subject
On Error Resume Next
Set myDestFolder = myFolder.Folders(FolderName1)
If myDestFolder Is Nothing Then
Set myNewFolder = myFolder.Parent.Folders.Add(FolderName1)
End If
olMail.Move myFolder.Parent.myDestFolder
Set olMail = Nothing
Set olNS = Nothing
End Sub
--------------------------------------------------------------------------------------
I am trying to classify my mails into folders automatically when it
arrives, I have used the run a script rule to achieve it. Whenever a
message arrives, I want the following to happen.
1) Make a folder with the name same as the subject within the personal
folder and not as subfolder in inbox
2) Move the mail to the new folder
With the help of my friends on this group, I was able to make up the
following code which unfortunately does not do the second part. Can
somone help me to kick the macro on the back.
I have tried the following
olMail.Move myFolder.Parent.myDestFolder
olMail.Move myDestFolder
olMail.Move Parent.myDestFolder
------------------------------------------------------------------------------
Sub AutomatingClassification(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
'Dim myFolder As Outlook.Folders
'Dim myDestFolder As Outlook.Folders
strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(strID)
' MsgBox olMail.Subject
Set myFolder = olNS.GetDefaultFolder(olFolderInbox)
FolderName1 = olMail.Subject
On Error Resume Next
Set myDestFolder = myFolder.Folders(FolderName1)
If myDestFolder Is Nothing Then
Set myNewFolder = myFolder.Parent.Folders.Add(FolderName1)
End If
olMail.Move myFolder.Parent.myDestFolder
Set olMail = Nothing
Set olNS = Nothing
End Sub
--------------------------------------------------------------------------------------