none
Send an alert to an email with current number of items in certain folders RRS feed

  • Question

  • Hi,

    I need a script that will send me an hourly update email about the current number of items in several folders in an Outlook configured email address.

    I have zero knowledge in vba so if anyone can help writing the script (if it's a quick one) it will be much appreciated.

    Thanks,

    Nir

    Wednesday, May 23, 2018 5:54 AM

All replies

  • Hi nirilan,

    For this requirement, you could try code below:

    Sub SendEmailCount()
        Dim objFolder As Folder
        Dim objNs As Outlook.NameSpace
        Set objNs = Application.GetNamespace("MAPI")
        Set objFolder = objNs.GetDefaultFolder(olFolderInbox).Folders("Thread") ' folder name
        MsgBox objFolder.Items.Count
    End Sub

    You could change the folder name based on your requirement.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 24, 2018 6:23 AM
  • Thank you so much. I need to configure this for multiple sub-folders, how can I do that (can you show me an example of a sub-folder syntax?)? and where do I configure to how frequently these alerts are sent (I want hourly) and to where they are sent?
    Thursday, May 24, 2018 2:20 PM
  • Hi nirilan,

    >>can you show me an example of a sub-folder syntax

    For this, you could access by the sub-folder path like below:

     Set objFolder = objNs.GetDefaultFolder(olFolderInbox).Folders("SubFolder").Folders("SubSubFolder") ' folder name

    If you still have any issue iwth sub-folder issue, I would suggest you post a new thread, and then we could focus on this specific issue.

    It is recommened to discuss one issue in one thread. For the rest issues, I would suggest you post new threads.

    For current thread, I would suggest you mark the solution as answer to close this issue.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, May 25, 2018 3:18 AM
  • Thank you, but I have no idea what the code you mentioned actually does. I mentioned specific requirements (send an hourly update by email about number of items in subfolders in another email) and this code does not seem to be what I need. But again, thanks for you time.
    Saturday, May 26, 2018 7:26 AM
  • Hi nirilan,

    >>send an hourly update by email about number of items in subfolders in another email

    For a detail requirement, we could split it into small part to promote problem solving.

    Your issue could be split into get subfolders mail account, then send to email.

    Do you have any trouble to get subfolder items account?

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 28, 2018 8:04 AM