Using "Rules" to copy incoming email into a folder.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please advise how I can use "Rules" to copy incoming email into a folder with
the same reference. This would have to recognise a code "EN####" where the
hash is a number.

ie EN1234,
EN1235
En1236 etc

Assume the folders are already created!
 
Rules aren't smart enough to do wildcard matching on message contents. You'd
have to write a VBA macro and wire it up so that it fires from other criteria:

How to create a script for the Rules Wizard in Outlook:
http://support.microsoft.com/default.aspx?scid=KB;en-us;q306108

If all of the message data is completely dynamic and a rule can't be created
that satisfies some basic criteria, you'd have to code everything and bypass
rules altogether:

How to create a custom rule in Outlook 2000 by using Visual Basic for
Applications:
http://support.microsoft.com/?kbid=235852
 
This sounds like a good project for a "run a script" rule action, which uses not an external script but a VBA procedure with a MailItem or MeetingItem as its parameter. That item is processed by the code:


Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msg As Outlook.MailItem
Dim rply as Outlook.MailItem

strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set msg = olNS.GetItemFromID(strID)
' do stuff with msg, e.g.
Set rply = msg.Reply
rply.Body = "What you want the reply to say."
rply.To = "(e-mail address removed); (e-mail address removed)"
rply.Send

Set msg = Nothing
Set rply = Nothing
Set olNS = Nothing
End Sub

For Outlook VBA basics, see http://outlookcode.com/article.aspx?id=49

You can use the Instr() and Mid() functions for basic string parsing, if you don't want to dive into regular expressions.

To get a non-default folder, you need to walk the folder hierarchy using the Folders collections or use a function that does that for you. See http://www.outlookcode.com/d/code/getfolder.htm.
 
Back
Top