O
Only_me
Hi, I just started with VB to create a VERY simple Outlook 2000
script.
It just takes the first email in a folder, gives it the title "a", and
then tests the title. How come the third check fails (see **** ERROR
IS HERE).
I am obviously stupid. Please help.
Sub test()
Set CurFolder = Application.ActiveExplorer.CurrentFolder
Set AllItems = CurFolder.Items
Set thisMail = AllItems.Item(1)
thisMail.Subject = "a"
If Not thisMail.Subject = "a" Then
MsgBox "ERROR: Pre-save"
End If
thisMail.Save
If Not thisMail.Subject = "a" Then
MsgBox "ERROR: Post-save"
End If
Set thisMail = AllItems.Item(1)
If Not thisMail.Subject = "a" Then
MsgBox "ERROR after get item again" '**** ERROR IS HERE
End If
thisMail.Subject = "b"
thisMail.Save
End Sub
Note: I tried removing all the "sort by" columns, in case the mails
were being sorted by subject or something. I still get the problem. I
used the "step into" to see what was happening line-by-line.
If I just keep pressing F8 to step-through, I get the same error.
HOWEVER, the weird thing is that if I hover the mouse over one of the
"thisMail"'s in the code as I step through, IT WORKS!!
This is repeatable every time. My brain hurts.
script.
It just takes the first email in a folder, gives it the title "a", and
then tests the title. How come the third check fails (see **** ERROR
IS HERE).
I am obviously stupid. Please help.
Sub test()
Set CurFolder = Application.ActiveExplorer.CurrentFolder
Set AllItems = CurFolder.Items
Set thisMail = AllItems.Item(1)
thisMail.Subject = "a"
If Not thisMail.Subject = "a" Then
MsgBox "ERROR: Pre-save"
End If
thisMail.Save
If Not thisMail.Subject = "a" Then
MsgBox "ERROR: Post-save"
End If
Set thisMail = AllItems.Item(1)
If Not thisMail.Subject = "a" Then
MsgBox "ERROR after get item again" '**** ERROR IS HERE
End If
thisMail.Subject = "b"
thisMail.Save
End Sub
Note: I tried removing all the "sort by" columns, in case the mails
were being sorted by subject or something. I still get the problem. I
used the "step into" to see what was happening line-by-line.
If I just keep pressing F8 to step-through, I get the same error.
HOWEVER, the weird thing is that if I hover the mouse over one of the
"thisMail"'s in the code as I step through, IT WORKS!!
This is repeatable every time. My brain hurts.