verify and delete mailitem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Daily I receive approx 100 emails. I have to open them individually
and verify that this line is present

Description: Successful

If it is present, I delete the email.

I think I should be able to do this programmatically, looping thru all
the emails in the collection and maybe doing a ctrl/find to locate the
text string and if it is present, close (maybe I don't have to close
it first?) and then delete the email. If the string is not present,
close the email and goto the next one without deleting. I am a bit
familiar with VBA in Word but rather outside my league here in
Outlook.

Here is my best guess on how to approach this and at least get
started:

Public Sub Deletions()
Dim obj As Object
Dim Items As Outlook.MailItem

Set Items = Application.Session.GetDefaultFolder(olFolderInbox).Items
For Each obj In Items
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Description: Successful"

here I think I need an if then statement saying if the
string is present, delete the item, if not close the item
only I can't think through it enough to figure out how to
tell the program that the text is indeed there (or not!)

End With
Next
End Sub

Would it be best to put the code to do this in the
'ThisOutlookSession' Module? I've never used the module and am not at
all sure when it should be used as verses just creating a new module.

Could someone please help me out with this. I sure appreciate your
time and expertise. I have spent the morning reading through this
group and that is how I came up with this 'best guess' of mine on how
to do this task. This newsgroup is chuck full of great info. Good job
and thanks a million. I love that you give us web sites to visit and
try to find the answers to our problems. While I wait for a response
to my inquiry I am going to go to Sue Mosher's site and check it out.
Joanne



.



Relevant Pages

  • Can anyone help RaiseEvent
    ... Public Sub raiseEventInCTIToolbar(p_strEventName As String) ... Dim obj ... My problem is when I double click script.vbs,msgbox "a" didn't show ...
    (microsoft.public.vb.general.discussion)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: multiplatform (pocketPC & desktopPC) (Daniel !!)
    ... Friend Versione As String ... Public Sub GetMyConnectionPalmare() ... Dim errorMessages As String ... Private Function GetDS_Desktop(ByVal SQL As String) As DataSet ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: hyperlinks in a paragraph
    ... Public Sub Discover(ByVal MStr As String) ... Public Sub ProcPara ... Dim HL As Hyperlink ...
    (microsoft.public.word.vba.general)
  • Re: Custom Action or Script to Purge Deleted Messages on IMAP acco
    ... Public Const DIRK_IMAP_ENTRYID As String = ... Dim oFld As Outlook.MAPIFolder ... Public Sub DeleteIMAPKANTOOR() ...
    (microsoft.public.outlook.program_vba)