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

Move and create folder based on subject



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 25th 07, 11:08 AM posted to microsoft.public.outlook.program_vba
Peter R.
external usenet poster
 
Posts: 1
Default 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.
Ads
  #2  
Old November 26th 07, 06:31 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default 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.

  #3  
Old December 4th 07, 03:51 PM posted to microsoft.public.outlook.program_vba
Peter R.[_2_]
external usenet poster
 
Posts: 7
Default 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.


  #4  
Old December 5th 07, 05:46 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default 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.


 




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 email messages to a specified folder based on a category DougLost Outlook and VBA 2 October 7th 10 03:18 PM
Move email to folder based on ReceivedTime [email protected] Outlook and VBA 1 July 18th 07 07:59 AM
How to create a rule to move emails based on a particular domain Net Outlook - General Queries 3 November 22nd 06 01:35 PM
Move emails to a folder rule (Time based) George Lake Outlook - General Queries 1 April 27th 06 03:09 PM
Move mail to a folder based on 2 different words in the subject fi Alan Kirkham Outlook and VBA 2 February 14th 06 02:34 PM


All times are GMT +1. The time now is 08:01 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-2025 Outlook Banter.
The comments are property of their posters.