converted from outlook2003 to outlook2007, thismessageitem automatic process

N

nina

All of our office systems were upgraded from outlook2003 to outlook2007

I used to run for each incoming email, a short vba code that would simply
log the headers to a drive but can't remember now how I initialized it?

Can someone help me?

Basically, I want to run a simple piece of vba code, similar to snippet
below and have this run for every incoming email

I inserted the code via Alt-F11 and saved it but can't remember how do I set
the rule to run this when mail arrives.


Sub CustomMailMessageRule(ByVal Item As MailItem)

On Error GoTo CustomMailMessageRule_Error

Dim olNS As Outlook.NameSpace

Set olNS = Application.GetNamespace("MAPI")

Dim Msg As Outlook.MailItem

strID = Item.EntryID
Set Msg = olNS.GetItemFromID(strID)

' write routine goes here, no problems with that

CustomMailMessageRule_Error:

Exit Sub

End Sub
 
N

Nina

Graham said:

Thank you, I had actually already read the KB article and it still leaves me
without the answer.

Permit me to illustrate a little more:

1. I have the precise code example for outlook.mailitem
2. How do I initialize it from Rules and Alerts ?

I have no link to anything when I select

1. New Rule
2. Check messages when they arrive
3. Run a script shows no script or macro or code to link to ??

Pressing ALT-F11 shows I have saved the VBA code in ThisOutlookSession

How do I link my Sub and Mailitem to the Rules ?
 
G

Graham Mayor

It doesn't matter which module it is stored but the detail in the brackets
is important. Change your macro name to

Sub CustomMailMessageRule(Item As Outlook.MailItem)

which is as shown in the linked page, and it should appear in your list of
Scripts from the Rules editor. The editor will not see your original

Sub CustomMailMessageRule(ByVal Item As MailItem)


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top