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

Adding a date to the Subject line in a rule



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 16th 07, 07:30 PM posted to microsoft.public.outlook.program_vba
cableguy47905 via OfficeKB.com
external usenet poster
 
Posts: 7
Default Adding a date to the Subject line in a rule

I am wanting to create a rule with the action to add today's date to the
subject line before moving it to another folder.

Can I do this? If so, does anyone have any code that would get me started on
it? I have done some coding in Access, but I have never attempted in Outlook.


Any help would be appreciated.

Thanks,
Lee

--
Message posted via http://www.officekb.com

Ads
  #2  
Old April 16th 07, 10:20 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Adding a date to the Subject line in a rule

This is how you incorporate VBA with an existing rule:

How to create a script for the Rules Wizard in Outlook:
http://support.microsoft.com/default...n-us%3bq306108

You still need the code to move the item and update it, but that's
relatively straightforward. Call MailItem.Move(MAPIFolder), where MAPIFolder
is a previously set variable to the destination folder. You either need to
"walk" the Namespace.Folders collection (eg. Namespace.Folders("Mailbox -
John Doe").Folders("Inbox").Folders("Subfolder")), or if you know the EntryID
value use that with the Namespace.GetFolderFromID method.

The subject line change is the easiest part - MailItem.Subject =
MailItem.Subject & " (" & Date & ")"

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cableguy47905 via OfficeKB.com" wrote:

I am wanting to create a rule with the action to add today's date to the
subject line before moving it to another folder.

Can I do this? If so, does anyone have any code that would get me started on
it? I have done some coding in Access, but I have never attempted in Outlook.


Any help would be appreciated.

Thanks,
Lee

--
Message posted via http://www.officekb.com


  #3  
Old April 17th 07, 05:45 PM posted to microsoft.public.outlook.program_vba
cableguy47905 via OfficeKB.com
external usenet poster
 
Posts: 7
Default Adding a date to the Subject line in a rule

Once I add the date to the subject, then I want to move it to a Personal
folder that is not in my mailbox. Is this possible? I really have no idea
how I should label the path.
I had checked out the MS KB, but it didn't really have very indepth examples.
Thanks again for the help.
Lee

Eric Legault [MVP - Outlook] wrote:
This is how you incorporate VBA with an existing rule:

How to create a script for the Rules Wizard in Outlook:
http://support.microsoft.com/default...n-us%3bq306108

You still need the code to move the item and update it, but that's
relatively straightforward. Call MailItem.Move(MAPIFolder), where MAPIFolder
is a previously set variable to the destination folder. You either need to
"walk" the Namespace.Folders collection (eg. Namespace.Folders("Mailbox -
John Doe").Folders("Inbox").Folders("Subfolder")), or if you know the EntryID
value use that with the Namespace.GetFolderFromID method.

The subject line change is the easiest part - MailItem.Subject =
MailItem.Subject & " (" & Date & ")"

I am wanting to create a rule with the action to add today's date to the
subject line before moving it to another folder.

[quoted text clipped - 6 lines]
Thanks,
Lee


--
Message posted via http://www.officekb.com

  #4  
Old April 17th 07, 06:54 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Adding a date to the Subject line in a rule

Yup, you can still move the message to another data file. Every loaded .pst
is like a top-level folder in the Namespace.Folders collection. So your
first .pst will be in Namespace.Folders(1), your 2nd in Namespace.Folders(2),
etc. So you'd have to loop through the top level or find it by name
(Namespace.Folders("My Personal Folders File").Folders("My Root Folder").

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cableguy47905 via OfficeKB.com" wrote:

Once I add the date to the subject, then I want to move it to a Personal
folder that is not in my mailbox. Is this possible? I really have no idea
how I should label the path.
I had checked out the MS KB, but it didn't really have very indepth examples.
Thanks again for the help.
Lee

Eric Legault [MVP - Outlook] wrote:
This is how you incorporate VBA with an existing rule:

How to create a script for the Rules Wizard in Outlook:
http://support.microsoft.com/default...n-us%3bq306108

You still need the code to move the item and update it, but that's
relatively straightforward. Call MailItem.Move(MAPIFolder), where MAPIFolder
is a previously set variable to the destination folder. You either need to
"walk" the Namespace.Folders collection (eg. Namespace.Folders("Mailbox -
John Doe").Folders("Inbox").Folders("Subfolder")), or if you know the EntryID
value use that with the Namespace.GetFolderFromID method.

The subject line change is the easiest part - MailItem.Subject =
MailItem.Subject & " (" & Date & ")"

I am wanting to create a rule with the action to add today's date to the
subject line before moving it to another folder.

[quoted text clipped - 6 lines]
Thanks,
Lee


--
Message posted via http://www.officekb.com


  #5  
Old April 17th 07, 10:53 PM posted to microsoft.public.outlook.program_vba
cableguy47905 via OfficeKB.com
external usenet poster
 
Posts: 7
Default Adding a date to the Subject line in a rule

Do you have an example that I might be able to use? So far I have:

Sub CustomMailMessageRule(Item As Outlook.MailItem)
Item.Subject = Item.Subject & " ( " & Date & " ) "
Item.Move(
End Sub


I know my personal folder is located : M:\Emails.pst
The folder within that would be "Emails to file away"
I also have my Archive folder that is listed just above the personal folder
in the tree and in the data file management tool.

Would you be able to help with all of that info?

Whenever I try to use NameSpace.something, it doesn't recognize the command.
I am really clueless when it comes to coding in here. I greatly appreciate
the help/bottle feeding.
Thanks,
Lee

Eric Legault [MVP - Outlook] wrote:
Yup, you can still move the message to another data file. Every loaded .pst
is like a top-level folder in the Namespace.Folders collection. So your
first .pst will be in Namespace.Folders(1), your 2nd in Namespace.Folders(2),
etc. So you'd have to loop through the top level or find it by name
(Namespace.Folders("My Personal Folders File").Folders("My Root Folder").

Once I add the date to the subject, then I want to move it to a Personal
folder that is not in my mailbox. Is this possible? I really have no idea

[quoted text clipped - 23 lines]
Thanks,
Lee


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...g-vba/200704/1

  #6  
Old April 19th 07, 06:56 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Adding a date to the Subject line in a rule

Sure. Take a look at this:

Dim myNameSpace As Outlook.NameSpace
Dim myPST As Outlook.MAPIFolder
Dim myFolder As Outlook.MAPIFolder

Set myNameSpace = Application.GetNamespace("MAPI")
Set myPST = myNameSpace.Folders("My PST DISPLAY NAME")
Set myFolder = myPST.Folders("Emails to file away")

Just change "My PST DISPLAY NAME" to whatever the root of your .pst is
labelled as when you look at it fully expanded. The code also assumes that
the "Emails to file away" folder is a top-level folder within that .pst.

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cableguy47905 via OfficeKB.com" wrote:

Do you have an example that I might be able to use? So far I have:

Sub CustomMailMessageRule(Item As Outlook.MailItem)
Item.Subject = Item.Subject & " ( " & Date & " ) "
Item.Move(
End Sub


I know my personal folder is located : M:\Emails.pst
The folder within that would be "Emails to file away"
I also have my Archive folder that is listed just above the personal folder
in the tree and in the data file management tool.

Would you be able to help with all of that info?

Whenever I try to use NameSpace.something, it doesn't recognize the command.
I am really clueless when it comes to coding in here. I greatly appreciate
the help/bottle feeding.
Thanks,
Lee

Eric Legault [MVP - Outlook] wrote:
Yup, you can still move the message to another data file. Every loaded .pst
is like a top-level folder in the Namespace.Folders collection. So your
first .pst will be in Namespace.Folders(1), your 2nd in Namespace.Folders(2),
etc. So you'd have to loop through the top level or find it by name
(Namespace.Folders("My Personal Folders File").Folders("My Root Folder").

Once I add the date to the subject, then I want to move it to a Personal
folder that is not in my mailbox. Is this possible? I really have no idea

[quoted text clipped - 23 lines]
Thanks,
Lee


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...g-vba/200704/1


  #7  
Old April 20th 07, 04:23 PM posted to microsoft.public.outlook.program_vba
cableguy47905 via OfficeKB.com
external usenet poster
 
Posts: 7
Default Adding a date to the Subject line in a rule

Thanks again for all of your help.

This is what I have.

Sub CustomMailMessageRule(Item As Outlook.MailItem)

Dim myNameSpace As Outlook.NameSpace
Dim myPST As Outlook.MAPIFolder
Dim myFolder As Outlook.MAPIFolder

Set myNameSpace = Application.GetNamespace("MAPI")
Set myPST = myNameSpace.Folders("M:\Emails.pst")
Set myFolder = myPST.Folders("0 Emails to file away")

Item.Subject = Item.Subject & " ( " & Now() & " ) "
Item.Move(myFolder)
End Sub

It is like it is ignoring the script. I have th emacros enabled. It will do
all of the other actions.
First it looks to see if I am in the CC, if so it will flag it red, and then
read the script to date and move it to my folder. All it does is flag it. I
can still have it move to the folder if I choose that option, but it still
won't date it.

What am I doing wrong?

Thanks,
Lee

Eric Legault [MVP - Outlook] wrote:
Sure. Take a look at this:

Dim myNameSpace As Outlook.NameSpace
Dim myPST As Outlook.MAPIFolder
Dim myFolder As Outlook.MAPIFolder

Set myNameSpace = Application.GetNamespace("MAPI")
Set myPST = myNameSpace.Folders("My PST DISPLAY NAME")
Set myFolder = myPST.Folders("Emails to file away")

Just change "My PST DISPLAY NAME" to whatever the root of your .pst is
labelled as when you look at it fully expanded. The code also assumes that
the "Emails to file away" folder is a top-level folder within that .pst.

Do you have an example that I might be able to use? So far I have:

[quoted text clipped - 27 lines]
Thanks,
Lee


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...g-vba/200704/1

  #8  
Old April 20th 07, 05:24 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Adding a date to the Subject line in a rule

Almost there! We don't want the file name of your .pst, we want the *display
name*! Make sure your .pst is expanded so you can see all of your folders -
click the Folder icon in the navigation pane so it shows "Folder List".
Whatever the label is for the root of your .pst is the display name.

You should also call Item.Save before you move it.

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"cableguy47905 via OfficeKB.com" wrote:

Thanks again for all of your help.

This is what I have.

Sub CustomMailMessageRule(Item As Outlook.MailItem)

Dim myNameSpace As Outlook.NameSpace
Dim myPST As Outlook.MAPIFolder
Dim myFolder As Outlook.MAPIFolder

Set myNameSpace = Application.GetNamespace("MAPI")
Set myPST = myNameSpace.Folders("M:\Emails.pst")
Set myFolder = myPST.Folders("0 Emails to file away")

Item.Subject = Item.Subject & " ( " & Now() & " ) "
Item.Move(myFolder)
End Sub

It is like it is ignoring the script. I have th emacros enabled. It will do
all of the other actions.
First it looks to see if I am in the CC, if so it will flag it red, and then
read the script to date and move it to my folder. All it does is flag it. I
can still have it move to the folder if I choose that option, but it still
won't date it.

What am I doing wrong?

Thanks,
Lee

Eric Legault [MVP - Outlook] wrote:
Sure. Take a look at this:

Dim myNameSpace As Outlook.NameSpace
Dim myPST As Outlook.MAPIFolder
Dim myFolder As Outlook.MAPIFolder

Set myNameSpace = Application.GetNamespace("MAPI")
Set myPST = myNameSpace.Folders("My PST DISPLAY NAME")
Set myFolder = myPST.Folders("Emails to file away")

Just change "My PST DISPLAY NAME" to whatever the root of your .pst is
labelled as when you look at it fully expanded. The code also assumes that
the "Emails to file away" folder is a top-level folder within that .pst.

Do you have an example that I might be able to use? So far I have:

[quoted text clipped - 27 lines]
Thanks,
Lee


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...g-vba/200704/1


  #9  
Old April 20th 07, 06:02 PM posted to microsoft.public.outlook.program_vba
cableguy47905 via OfficeKB.com
external usenet poster
 
Posts: 7
Default Adding a date to the Subject line in a rule

I made that change. It still seems to ignore it.

Sub CustomMailMessageRule(Item As Outlook.MailItem)

Dim myNameSpace As Outlook.NameSpace
Dim myPST As Outlook.MAPIFolder
Dim myFolder As Outlook.MAPIFolder

Set myNameSpace = Application.GetNamespace("MAPI")
Set myPST = myNameSpace.Folders("Personal Folders")
Set myFolder = myPST.Folders("0 Emails to file away")

Item.Subject = Item.Subject & " ( " & Now() & " ) "
Item.Save
Item.Move (myFolder)
End Sub

Do I need to have something activated somewhere else? It doesn't error out,
it just ignores it. It is probably something simple that I have forgotten to
do.

Thanks,
Lee

Eric Legault [MVP - Outlook] wrote:
Almost there! We don't want the file name of your .pst, we want the *display
name*! Make sure your .pst is expanded so you can see all of your folders -
click the Folder icon in the navigation pane so it shows "Folder List".
Whatever the label is for the root of your .pst is the display name.

You should also call Item.Save before you move it.

Thanks again for all of your help.

[quoted text clipped - 45 lines]
Thanks,
Lee


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...g-vba/200704/1

  #10  
Old April 20th 07, 06:34 PM posted to microsoft.public.outlook.program_vba
cableguy47905 via OfficeKB.com
external usenet poster
 
Posts: 7
Default Adding a date to the Subject line in a rule

Ok, it looks like I can't run any other action with the script. So I
modified it so that it will also flag the message, date it, and then move it.
It does flag, and date it, but I still can't get it to move it just yet. It
must be the format that I am puting the name in it. I will get this worked
out, I just know it.

This is what I have.
Sub CustomMailMessageRule(Item As Outlook.MailItem)

Dim myNameSpace As Outlook.NameSpace
Dim myPST As Outlook.MAPIFolder
Dim myFolder As Outlook.MAPIFolder

Set myNameSpace = Application.GetNamespace("MAPI")
Set myPST = myNameSpace.Folders("Personal Folders")
Set myFolder = myPST.Folders("0 Emails to file away")

Item.FlagStatus = olFlagMarked
Item.Subject = Item.Subject & " ( " & Now() & " ) "
Item.Save
Item.Move (myFolder)
End Sub

Does my .pst folder have to be in a certain drive? How does it know where to
look for the actual .pst?

Thanks,
Lee
Almost there! We don't want the file name of your .pst, we want the *display
name*! Make sure your .pst is expanded so you can see all of your folders -

[quoted text clipped - 8 lines]
Thanks,
Lee


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...g-vba/200704/1

 




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
predefined subject line with date dries Outlook and VBA 3 February 5th 07 09:54 PM
Subject Line? Lime Outlook - Using Forms 12 December 7th 06 03:45 AM
Subject Line? Lime Outlook - General Queries 1 December 6th 06 06:47 PM
Subject line Peter Outlook Express 1 May 21st 06 10:10 AM
lost subject line Tony Iorio Outlook - General Queries 1 January 18th 06 11:56 AM


All times are GMT +1. The time now is 04:06 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.