How do i add the date to subject header of incoming mail?

  • Thread starter Thread starter primed
  • Start date Start date
P

primed

Hi,

How do i automatically add the date yy/mm/dd to the front of the subject
header of incoming mail? Would gather its something to do with create rules
then run script, but cant workout how to create a script.

Thanks
Primed
 
The script that can be run by a rule must look like this:

Public Sub Whatever(Mail as Outlook)
Mail.Subject=Date & " " & Mail.Subject
Mail.Save
End Sub

--
Best regards
Michael Bauer - MVP Outlook
Category Manager - Manage and share your categories:
SAM - The Sending Account Manager:
<http://www.vboffice.net/product.html?lang=en>


Am Wed, 31 Mar 2010 22:47:01 -0700 schrieb primed:
 
Sorry, the first line should look like this:

Public Sub Whatever(Mail as Outlook.MailItem)

--
Best regards
Michael Bauer - MVP Outlook
Category Manager - Manage and share your categories:
SAM - The Sending Account Manager:
<http://www.vboffice.net/product.html?lang=en>


Am Mon, 5 Apr 2010 17:41:02 -0700 schrieb primed:
 
Cheers, that works better.
Can the date be reversed so its like this 100407


Also can the files attached to the document be renamed to have the same date
before them.

Thanks
Primed
 
The script doesnt run when the rule is initiated automatically. ie
when the mail comes in. The other aspects of the rule work just not the
script.

When i run the rule manually, through the apply rule to existing mail tick
box everything works good.

Any ideas?
 
1) See the Format function.

2) I've never tried it, but AFAIK you can't rename an attached file, instead
you'd have first to rename the file, then attach it. For that you could
monitor AttachmentAdd function: If you detect a file has been attached, save
it as a file, remove it from the email, rename the file, and attach it
again.

--
Best regards
Michael Bauer - MVP Outlook
Category Manager - Manage and share your categories:
SAM - The Sending Account Manager:
<http://www.vboffice.net/product.html?lang=en>


Am Tue, 6 Apr 2010 17:03:01 -0700 schrieb primed:
 
Maybe there's another rule working on the received message for that you have
set the "don't execute more rules" action?

--
Best regards
Michael Bauer - MVP Outlook
Category Manager - Manage and share your categories:
SAM - The Sending Account Manager:
<http://www.vboffice.net/product.html?lang=en>

Am Tue, 6 Apr 2010 18:01:01 -0700 schrieb primed:
 
To that function you can pass the format you want, use YY for a two digit
year, YYYY for a four digit year, etc.

--
Best regards
Michael Bauer - MVP Outlook
Category Manager - Manage and share your categories:
SAM - The Sending Account Manager:
<http://www.vboffice.net/product.html?lang=en>


Am Wed, 7 Apr 2010 17:13:01 -0700 schrieb primed:
 
Hi

i've never created a script before and hope i have done it correctly

i opened Tool>Macro>Visual Basic Editor
inserted a new module
copied in

Public Sub Whatever(Mail As Outlook.MailItem)
Mail.Subject = Date & " " & Mail.Subject
Mail.Save
End Sub

and saved

then in Tools>Rules and Alerts and created a new rule

Apply this rule after the message arrives
on this machine only
run Project1.Whatever

i ran it on my inbox an sent myself an email and nothing happens

im on office outlook 2003 SP2

many thanks
Darre
 
Does it make a difference if you move the code from the module to
ThisOutlookSession? (Don't forget to edit the rule, too.)

If not, set a breakpoint (f9) on the first line of code. Does the code
execution stopps there when a new message arrives?

--
Best regards
Michael Bauer - MVP Outlook
Category Manager - Manage and share your categories:
SAM - The Sending Account Manager:
<http://www.vboffice.net/product.html?lang=en>



Am Fri, 7 May 2010 10:47:41 +0100 schrieb DarrenD:
 
I have copied it to the ThisOutlookSession and created a new rule to
pick it up

i set the breakpoint on the line
Mail.Subject = Date & " " & Mail.Subject

sent a couple of emails to the account and they still got delivered
without any date in the subject bar



'Michael Bauer [MVP - Outlook said:
;348674']Does it make a difference if you move the code from the module
to
ThisOutlookSession? (Don't forget to edit the rule, too.)

If not, set a breakpoint (f9) on the first line of code. Does the code
execution stopps there when a new message arrives?

--
Best regards
Michael Bauer - MVP Outlook
Category Manager - Manage and share your categories:
SAM - The Sending Account Manager:
http://www.vboffice.net/product.html?lang=en



Am Fri, 7 May 2010 10:47:41 +0100 schrieb DarrenD:
-
Hi

i've never created a script before and hope i have done it correctly

i opened ToolMacroVisual Basic Editor
inserted a new module
copied in

Public Sub Whatever(Mail As Outlook.MailItem)
Mail.Subject = Date & " " & Mail.Subject
Mail.Save
End Sub

and saved

then in ToolsRules and Alerts and created a new rule

Apply this rule after the message arrives
on this machine only
run Project1.Whatever

i ran it on my inbox an sent myself an email and nothing happens

im on office outlook 2003 SP2

many thanks
Darren-
 
So the code execution doesn't stop there? Then check Tools/Macros/Security,
whether VBA is executed at all.

--
Best regards
Michael Bauer - MVP Outlook
Category Manager - Manage and share your categories:
SAM - The Sending Account Manager:
<http://www.vboffice.net/product.html?lang=en>


Am Fri, 14 May 2010 16:42:29 +0100 schrieb DarrenD:
I have copied it to the ThisOutlookSession and created a new rule to
pick it up

i set the breakpoint on the line
Mail.Subject = Date & " " & Mail.Subject

sent a couple of emails to the account and they still got delivered
without any date in the subject bar



'Michael Bauer [MVP - Outlook said:
;348674']Does it make a difference if you move the code from the module
to
ThisOutlookSession? (Don't forget to edit the rule, too.)

If not, set a breakpoint (f9) on the first line of code. Does the code
execution stopps there when a new message arrives?

--
Best regards
Michael Bauer - MVP Outlook
Category Manager - Manage and share your categories:
SAM - The Sending Account Manager:
http://www.vboffice.net/product.html?lang=en



Am Fri, 7 May 2010 10:47:41 +0100 schrieb DarrenD:
-
Hi

i've never created a script before and hope i have done it correctly

i opened ToolMacroVisual Basic Editor
inserted a new module
copied in

Public Sub Whatever(Mail As Outlook.MailItem)
Mail.Subject = Date & " " & Mail.Subject
Mail.Save
End Sub

and saved

then in ToolsRules and Alerts and created a new rule

Apply this rule after the message arrives
on this machine only
run Project1.Whatever

i ran it on my inbox an sent myself an email and nothing happens

im on office outlook 2003 SP2

many thanks
Darren-
 
Back
Top