Changed Subject not Saving (apparently??)

  • Thread starter Thread starter Wayne Ivory
  • Start date Start date
W

Wayne Ivory

Doing a Google search showed me that a few people had been caught by
trying to change the Subject line of an incoming message but forgot to
issue the Save method. I had also not put in a Save, however putting
one in didn't fix the problem.

The background. The Mail Monitor software on our server catches
incoming viruses and it sends us here in our IT Department an
acknowledgement. The subject of the acknowledgement is "Message
deleted" and I have a rule that moves these into a separate "Virus"
folder. The body of the acknowledgement contains lots of guff, but
what I wanted to do was extract the subject line of the original
message and append it to the "Message deleted" subject in brackets so
I could clearly see if it was one of the known Viruses (eg, "Microsoft
Critical Update") or perhaps an innocent message sent by an
unknowingly-infected person.

I'm using OL2002 so in my rule I selected "run a script" and pointed
it to the following procedure in ThisOutlookSession:

Sub VirusSubject(objMsg As MailItem)
Dim SubjectPos&

'Stop
'Debug.Print objMsg.Body
SubjectPos& = InStr(1, objMsg.Body, "Subject: ", vbBinaryCompare)
Debug.Print SubjectPos&
If SubjectPos& > 0 Then
Debug.Print objMsg.Subject & " (" & Mid$(objMsg.Body,
SubjectPos& + 9, InStr(SubjectPos&, objMsg.Body, vbCrLf) - SubjectPos&
- 9) & ")"
objMsg.Subject = objMsg.Subject & " (" & Mid$(objMsg.Body,
SubjectPos& + 9, InStr(SubjectPos&, objMsg.Body, vbCrLf) - SubjectPos&
- 9) & ")"
objMsg.Save
objMsg.Display
End If
Set objMsg = Nothing
End Sub

Originally I didn't have the Stop or Debug or Display statements.
Nothing seemed to be happening so I put in the Stop and Debug
statements. The next time a virus acknowledgement came in the Stop
activated. I stepped through the code and the Debug displayed the
amended Subject as I expected, but back in Outlook the Subject didn't
change!

I thought maybe I needed to reload Outlook into memory so I commented
out the Stop statement and closed Outlook. Subsequent virus
acknowledgements came in but the subject didn't change, AND when I
went into VBA there was no Debug output in the Immediate window!?

I thought maybe I needed to put in the Display statement so I did
this. I also thought that maybe changing the code might require
repicking the routine in the "run a script" part of the rule so I
removed that part of the rule and saved it, then put it back in and
selected the (now modified) procedure. Still no modified subject and
still no debug output in the immediate window. It's like the code is
somehow not running any more maybe?? Finally I put the Stop statement
back in to check but of course (wouldn't you know it) I haven't
received any virus acknowledgements for the last hour or so, therefore
I'm not sure if the code is running or not.

Can anybody think what might be happening here?

Thanks

Wayne Ivory
IT Analyst Programmer
Wespine Industries Pty Ltd
 
Okay, now I'm just totally confused. I created a new procedure called
Greeting that just displays a message box. Then I created a new Rule
called greeting that applies to ALL incoming emails and whose action
is to run the script Greeting, but nothing happens!!!

What's going on??

Thanks

Wayne
 
Back
Top