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

Search, Results and modifying subject



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 4th 08, 05:34 PM posted to microsoft.public.outlook.program_vba
Ptit Dark[_2_]
external usenet poster
 
Posts: 5
Default Search, Results and modifying subject

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  
Old September 4th 08, 06:45 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Search, Results and modifying subject

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  
Old September 9th 08, 01:17 PM posted to microsoft.public.outlook.program_vba
Ptit Dark[_2_]
external usenet poster
 
Posts: 5
Default Search, Results and modifying subject

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
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
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


All times are GMT +1. The time now is 08:47 PM.


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.