Chancing / remove “ something ” in the subject, online archive

Discussion in 'Outlook VBA and Custom Forms' started by Ronald1913, Oct 2, 2017.

  1. Ronald1913

    Ronald1913

    New Member
    Hi :)

    I need a macro for chancing / remove “ something ” in the subject, for all mails in the online archive ( office365 ).

    Thanks
     
  2. Diane Poremsky

    Diane Poremsky

    Senior Member
  3. Ronald1913

    Ronald1913

    New Member
    Hi

    Does this work for the online archive in office 365?
    I only need it for the online archive.
     
  4. Diane Poremsky

    Diane Poremsky

    Senior Member
    you need to run it in outlook, on a folder in the online archive. As the macros are written, they work either on the select items or all items in a folder, so you'd need to run it on each folder.

    I'm not aware of a way to do it completely online - powershell might be able to do it, but the admin would need to run it AFAIK. (I don't have a powershell script that can do it.)
     
  5. Ronald1913

    Ronald1913

    New Member
    Hi :)

    That is ok, so is it possible to run this macro on the main folder and all subfolders or is it necessary to run it on each folder?
    Yes powershell script is a option to.
     
  6. Ronald1913

    Ronald1913

    New Member
    Hi

    I can use this one to edit one email but it can't continue to the next email.

    Option Explicit
    Public Sub DoSomethingFolder()
    Dim objOL As Outlook.Application
    Dim objItems As Outlook.Items
    Dim objFolder As Outlook.MAPIFolder
    Dim obj As Object

    Set objOL = Outlook.Application
    Set objFolder = objOL.ActiveExplorer.CurrentFolder
    Set objItems = objFolder.Items

    For Each obj In objItems

    With obj

    obj.Subject = Replace(obj.Subject, "test", "")
    Debug.Print .Subject

    End With

    Next

    Set obj = Nothing
    Set objItems = Nothing
    Set objFolder = Nothing
    Set objOL = Nothing
    End Sub
     
  7. Diane Poremsky

    Diane Poremsky

    Senior Member
    that one should move to the next one - this part tells it to use the current folder and the items in that folder:
    Set objFolder = objOL.ActiveExplorer.CurrentFolder
    Set objItems = objFolder.Items
    For Each obj In objItems

    is the word (test in this example) in each subject?

    oh, one thing i see i forgot - you need to save the obj for the change to stick - and the keyword is case sensitive.


    I tweaked the code with the changes in this snippet -

    Code (Text):
    Copy Source
    Dim i As Long

    For Each obj In objItems

    With obj
    i = i + 1
    Debug.Print .Subject
    obj.Subject = Replace(LCase(obj.Subject), "test", "")
    obj.Save


    End With

    Next
    MsgBox i
     
     
  8. Ronald1913

    Ronald1913

    New Member
    Hi and Thanks !

    Yes it works fine now like this :
    Option Explicit
    Public Sub test()
    Dim objOL As Outlook.Application
    Dim objItems As Outlook.Items
    Dim objFolder As Outlook.MAPIFolder
    Dim obj As Object

    Set objOL = Outlook.Application
    Set objFolder = objOL.ActiveExplorer.CurrentFolder
    Set objItems = objFolder.Items

    Dim i As Long

    For Each obj In objItems

    With obj
    i = i + 1
    Debug.Print .Subject
    obj.Subject = Replace(obj.Subject, "test", "")
    obj.Save


    End With

    Next
    MsgBox i


    Set obj = Nothing
    Set objItems = Nothing
    Set objFolder = Nothing
    Set objOL = Nothing
    End Sub


    Only one thing more : is it possible for this macro to continue into subfolders ?
     
  9. Diane Poremsky

    Diane Poremsky

    Senior Member
Loading...

Share This Page