Consulting

Results 1 to 3 of 3

Thread: Loop Through Multiple Selected Mail Item

  1. #1

    Loop Through Multiple Selected Mail Item

    I am having issues on my 'For Next' statement and getting an "Operation Failed" error.

    the error shows up when x = 2

     
    For x = 1 To myOlSel.Count
     Set oMail = myOlSel.item(x)
     Set MyCurrentFolder = myOlExp.CurrentFolder
     
            If (TypeOf myOlSel.item(x) Is MailItem) Then
                oMail = myOlSel.item(x)
                ' code here to get mail item metadata (subject, conversationID, received time, category etc)
    
    
            End If
                oMail.UnRead = False
        Next x

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Moderator Bump
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Mentor skatonni's Avatar
    Joined
    Jun 2006
    Posts
    347
    Location
    Set oMail = myOlSel.item(x)
    Likely there are more problems. If so, put enough code for responders to run, instead of having to guess what you have.
    To debug, mouse-click anywhere in the code. Press F8 repeatedly to step through the code. http://www.cpearson.com/excel/DebuggingVBA.aspx

    If your problem has been solved in your thread, mark the thread "Solved" by going to the "Thread Tools" dropdown at the top of the thread. You might also consider rating the thread by going to the "Rate Thread" dropdown.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •