Delete not Deleting

  • Thread starter RGV2YWxpbGFKb2hu
  • Start date Views 1,155
R

RGV2YWxpbGFKb2hu

#1
I have a simple macro which is called as part of a rule. The rule is

triggered by certain strings in the Subject line. The macro saves the

attachments and then delets the message. The code (abbreviated) looks like:

Public Sub SaveAndDelete(theMail as MailItem)

Dim MyAtt As Attachment

Dim stSavePath As String

> .

> .

logic to assign the path for saving

> .

> .

For Each MyAtt in theMail.Attachments

MyAtt.SaveAsFile stSavePath & MyAtt.DisplayName

Next

theMail.Delete

End Sub

Everything works correctly when I test it on my machine (Outlook 2003 SP3 XP

Pro SP3). One of my users is finding that the files are being saved but the

messages are not being deleted. To compound the confusion, I'm not seeing

any errors being raised.

So that raises a couple of questions:

1. The obvious, why isn't it deleting?

2. How would I detect if a SAVE or DELETE fails?

TIA,

John
 
K

Ken Slovak - [MVP - Outlook]

#2
Could it be possible that the item that is being deleted where it doesn't

work is the only item in that folder's Items collection?

Do you have any error handling in that code?

What happens if you were to release the object theMail and then get a new

object by using NameSpace.GetItemFromID() using the EntryID of the theMail

item? Does that work when Delete() is called?

"DevalilaJohn" <DevalilaJohn> wrote in message

news:1652036A-7978-4FCE-AE25-287EE1A71124@microsoft.com...
> I have a simple macro which is called as part of a rule. The rule is
> triggered by certain strings in the Subject line. The macro saves the
> attachments and then delets the message. The code (abbreviated) looks
> like:

> Public Sub SaveAndDelete(theMail as MailItem)

> Dim MyAtt As Attachment
> Dim stSavePath As String
> .
> .
> logic to assign the path for saving
> .
> .
> For Each MyAtt in theMail.Attachments
> MyAtt.SaveAsFile stSavePath & MyAtt.DisplayName
> Next

> theMail.Delete
> End Sub

> Everything works correctly when I test it on my machine (Outlook 2003 SP3
> XP
> Pro SP3). One of my users is finding that the files are being saved but
> the
> messages are not being deleted. To compound the confusion, I'm not seeing
> any errors being raised.

> So that raises a couple of questions:
> 1. The obvious, why isn't it deleting?
> 2. How would I detect if a SAVE or DELETE fails?

> TIA,

> John

>
 

Similar threads

Top