![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hi everyone,
I look for some emails that I want to erase definitly. 'Cause vba cannot perform a shift+delete, I try to find a workaround. So I want to change the subject by a value (here it's date and time given by Now() function), then delete. Please see the code below. It deletes email no problem... it changes the subject, sometimes... like once for an hundred emails. I just thought it's a matter of speed. So if you remove the comments, I use a loop to make the subject changes until it changes and it causes an infinite loop. Dim oSearch As Outlook.Search, oResult As Outlook.Results Dim i As Integer, iNbEmail As Integer, sDelete As String blnSearchComp = False sDelete = Now Set oSearch = Application.AdvancedSearch("Sent Items", "my search params") While blnSearchComp = False DoEvents Wend Set oResult = oSearch.Results iNbEmail = oResult.Count For i = 1 To iNbEmail ' While oResult.Item(i).Subject sDelete oResult.Item(i).Subject = sDelete ' DoEvents ' Wend oResult.Item(i).Delete Next I need help. Badly ! I know I must do something wrong, but I can't figure out what. Thx |
Ads |
#2
|
|||
|
|||
![]()
You are not calling Save:
For i = 1 To iNbEmail set Item = oResult.Item(i). Item.Subject = sDelete Item.Delete Next -- Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "Ptit Dark" wrote in message ... Hi everyone, I look for some emails that I want to erase definitly. 'Cause vba cannot perform a shift+delete, I try to find a workaround. So I want to change the subject by a value (here it's date and time given by Now() function), then delete. Please see the code below. It deletes email no problem... it changes the subject, sometimes... like once for an hundred emails. I just thought it's a matter of speed. So if you remove the comments, I use a loop to make the subject changes until it changes and it causes an infinite loop. Dim oSearch As Outlook.Search, oResult As Outlook.Results Dim i As Integer, iNbEmail As Integer, sDelete As String blnSearchComp = False sDelete = Now Set oSearch = Application.AdvancedSearch("Sent Items", "my search params") While blnSearchComp = False DoEvents Wend Set oResult = oSearch.Results iNbEmail = oResult.Count For i = 1 To iNbEmail ' While oResult.Item(i).Subject sDelete oResult.Item(i).Subject = sDelete ' DoEvents ' Wend oResult.Item(i).Delete Next I need help. Badly ! I know I must do something wrong, but I can't figure out what. Thx |
#3
|
|||
|
|||
![]()
It worked !! Thx a lot
"Dmitry Streblechenko" wrote: You are not calling Save: For i = 1 To iNbEmail set Item = oResult.Item(i). Item.Subject = sDelete Item.Delete Next -- Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool - "Ptit Dark" wrote in message ... Hi everyone, I look for some emails that I want to erase definitly. 'Cause vba cannot perform a shift+delete, I try to find a workaround. So I want to change the subject by a value (here it's date and time given by Now() function), then delete. Please see the code below. It deletes email no problem... it changes the subject, sometimes... like once for an hundred emails. I just thought it's a matter of speed. So if you remove the comments, I use a loop to make the subject changes until it changes and it causes an infinite loop. Dim oSearch As Outlook.Search, oResult As Outlook.Results Dim i As Integer, iNbEmail As Integer, sDelete As String blnSearchComp = False sDelete = Now Set oSearch = Application.AdvancedSearch("Sent Items", "my search params") While blnSearchComp = False DoEvents Wend Set oResult = oSearch.Results iNbEmail = oResult.Count For i = 1 To iNbEmail ' While oResult.Item(i).Subject sDelete oResult.Item(i).Subject = sDelete ' DoEvents ' Wend oResult.Item(i).Delete Next I need help. Badly ! I know I must do something wrong, but I can't figure out what. Thx |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Search through all users calenders with subject text as search criteria | Mads Westen | Outlook and VBA | 3 | August 7th 08 03:39 PM |
search results in Outlook | Sertel Sen | Outlook - Using Contacts | 5 | January 14th 08 01:12 AM |
Successful search results returns a blank "Full Name" in results | Sharam | Outlook - Using Contacts | 11 | January 6th 08 04:41 AM |
Search Results Order | Frank | Outlook - General Queries | 5 | November 3rd 06 08:57 PM |
Search Results | Frema Luther | Outlook Express | 4 | August 25th 06 07:09 PM |