A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Run a Scipt - Move to folder - Got stuck



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old August 1st 06, 07:00 AM posted to microsoft.public.outlook.program_vba
RosH
external usenet poster
 
Posts: 4
Default Run a Scipt - Move to folder - Got stuck

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
--------------------------------------------------------------------------------------

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Move data folder Leah S Outlook - General Queries 2 July 31st 06 05:34 PM
move Notes to a folder Carl R Outlook - General Queries 0 July 16th 06 07:39 PM
move to Outlook Folder Hlewis Outlook and VBA 9 March 27th 06 01:39 PM
Outlook Folder Move Event Atul Sureka Outlook and VBA 0 February 13th 06 05:09 AM
Cannot move/delete messages from Sent folder KBAR Outlook Express 1 February 10th 06 03:49 PM


All times are GMT +1. The time now is 05:10 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.