![]() |
Move and create folder based on subject
I sell thrue Ebay and get lots of questions. The subject is always like
"Member: name123" or "user: name57177". I want to store each message in a folder with the same name. I want my program to check if the folder name123 already exists, if not create it, and move the message to that specific folder. Could anybody give me some hints how to do this. Thanks a lot Peter. |
Move and create folder based on subject
Please see the VBA help for the ItemAdd event, which tells you when an item arrives. Then you migth try this sample: On Error Resume Next Dim Find$ Dim Name$ Dim Pos& Dim F as Outlook.Mapifolder Dim Inbox as Outlook.MapiFolder Find="Member: " Pos= Instr(1, Item.Subject, Find, vbTextCompare) If Pos Then Pos = Pos + Len(Find) Name = Mid$(Item.Subject, Pos) Set Inbox = Application.Session.GetDefaultFolder(olFolderinbox ) Set F = Inbox.Folders(Name) If F is Nothing Then Set F = Inbox.Folders.Add(Name) Endif Item.Move F EndIf -- Best regards Michael Bauer - MVP Outlook Synchronize Color Categories & Ensure that Every Item Gets Categorized: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Sun, 25 Nov 2007 03:08:00 -0800 schrieb Peter R.: I sell thrue Ebay and get lots of questions. The subject is always like "Member: name123" or "user: name57177". I want to store each message in a folder with the same name. I want my program to check if the folder name123 already exists, if not create it, and move the message to that specific folder. Could anybody give me some hints how to do this. Thanks a lot Peter. |
Move and create folder based on subject
Dear Michael thanks for your anwer,
I get an error on this when the folder is non existend Set F = Inbox.Folders(Name) how do I check that before to avoid this error from happening. Thanks again Michael or anybody else. I have one problem, "Michael Bauer [MVP - Outlook]" wrote: Please see the VBA help for the ItemAdd event, which tells you when an item arrives. Then you migth try this sample: On Error Resume Next Dim Find$ Dim Name$ Dim Pos& Dim F as Outlook.Mapifolder Dim Inbox as Outlook.MapiFolder Find="Member: " Pos= Instr(1, Item.Subject, Find, vbTextCompare) If Pos Then Pos = Pos + Len(Find) Name = Mid$(Item.Subject, Pos) Set Inbox = Application.Session.GetDefaultFolder(olFolderinbox ) Set F = Inbox.Folders(Name) If F is Nothing Then Set F = Inbox.Folders.Add(Name) Endif Item.Move F EndIf -- Best regards Michael Bauer - MVP Outlook Synchronize Color Categories & Ensure that Every Item Gets Categorized: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Sun, 25 Nov 2007 03:08:00 -0800 schrieb Peter R.: I sell thrue Ebay and get lots of questions. The subject is always like "Member: name123" or "user: name57177". I want to store each message in a folder with the same name. I want my program to check if the folder name123 already exists, if not create it, and move the message to that specific folder. Could anybody give me some hints how to do this. Thanks a lot Peter. |
Move and create folder based on subject
This ignores the error: On Error Resume Next .... Set F = Inbox.Folders(Name) -- Best regards Michael Bauer - MVP Outlook Synchronize Color Categories & Ensure that Every Item Gets Categorized: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Tue, 4 Dec 2007 07:51:01 -0800 schrieb Peter R.: Dear Michael thanks for your anwer, I get an error on this when the folder is non existend Set F = Inbox.Folders(Name) how do I check that before to avoid this error from happening. Thanks again Michael or anybody else. I have one problem, "Michael Bauer [MVP - Outlook]" wrote: Please see the VBA help for the ItemAdd event, which tells you when an item arrives. Then you migth try this sample: On Error Resume Next Dim Find$ Dim Name$ Dim Pos& Dim F as Outlook.Mapifolder Dim Inbox as Outlook.MapiFolder Find="Member: " Pos= Instr(1, Item.Subject, Find, vbTextCompare) If Pos Then Pos = Pos + Len(Find) Name = Mid$(Item.Subject, Pos) Set Inbox = Application.Session.GetDefaultFolder(olFolderinbox ) Set F = Inbox.Folders(Name) If F is Nothing Then Set F = Inbox.Folders.Add(Name) Endif Item.Move F EndIf -- Best regards Michael Bauer - MVP Outlook Synchronize Color Categories & Ensure that Every Item Gets Categorized: http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6 Am Sun, 25 Nov 2007 03:08:00 -0800 schrieb Peter R.: I sell thrue Ebay and get lots of questions. The subject is always like "Member: name123" or "user: name57177". I want to store each message in a folder with the same name. I want my program to check if the folder name123 already exists, if not create it, and move the message to that specific folder. Could anybody give me some hints how to do this. Thanks a lot Peter. |
All times are GMT +1. The time now is 07:55 PM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com