A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Delete not Deleting



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 6th 09, 03:04 PM posted to microsoft.public.outlook.program_vba
DevalilaJohn
external usenet poster
 
Posts: 1
Default Delete not Deleting

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


  #2  
Old April 6th 09, 03:57 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Delete not Deleting

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?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"DevalilaJohn" wrote in message
...
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



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i add a Confirm Delete Dialog Box when deleting an appointm Curiser Outlook - Calandaring 1 January 17th 09 04:52 AM
How do I delete emails from profile w/o deleting from mainserver? Jeanfox Outlook - General Queries 0 June 24th 08 08:00 PM
delete account also deleting that accounts messages? Kim Outlook - General Queries 4 January 31st 07 06:01 PM
Meeting Invitation Keeps Deleting and Filling up my Delete Box mpfannen Outlook - Calandaring 0 October 25th 06 07:47 PM
deleting old entries - archiving does not delete them Sleb Outlook - Calandaring 0 May 11th 06 01:54 AM


All times are GMT +1. The time now is 10:37 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.