Consulting

Results 1 to 2 of 2

Thread: Delete emails after attachments are saved

  1. #1
    VBAX Newbie
    Joined
    Apr 2010
    Posts
    2
    Location

    Delete emails after attachments are saved

    Hi,

    I have the code below which is saving attachments from an Outlook subfolder to a directory. Once these attachments are saved I want to delete the emails.

    I've been told to use Item.Delete but the loop isn't working, it only picks up the first mail and then moves onto the rest of the code.

    Any ideas how to get around this?

    Here is the loop:

    [VBA]'Saves email attachments
    For Each Item In SubFolder.Items
    For Each Atmt In Item.Attachments
    If Right(Atmt.FileName, 3) = "xls" Then
    FileName = "N:\Investment\Performance Measurement\PERFMEAS - NUIM\EQUITY\CFD\59065\" & Atmt.FileName
    Atmt.SaveAsFile FileName
    Item.Delete
    i = i + 1

    End If
    Next Atmt

    Next Item[/VBA]





    Thanks

  2. #2
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    See your other thread.
    Regards,
    JP

    Read the FAQ
    Getting free help on the web
    My website
    Please use [vba][/vba] tags when posting code

Posting Permissions

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