Move and create folder based on subject

  • Thread starter Thread starter Peter R.
  • Start date Start date
P

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.
 
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.:
 
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,
 
Back
Top