Counting Mails in Outlook with Autohotkey










0














I tried to write a script, that counts the e-Mails in a specific public exchange folder in outlook.
If there are Mails in subfolder2, a Messagebox should open and tell me, how many Mails there are. I tried this, but it did not work.



 Outlook := ComObjActive("Outlook.Application")
mail = (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("SubfolderSubfolder2")
if (mail.Items.Count>0)

msgbox % mail.Items.Count "Mails in folder"

else

msgbox No Mails.



Does anyone has a idea, how I should change the script, that it works?










share|improve this question























  • What does " it did not work" mean? Did you get an error?
    – Dmitry Streblechenko
    Nov 13 at 15:20










  • It does not count the mails in the folder i want. The Script works, no errors. Just not the way, i want it to work.
    – PHS
    Nov 14 at 6:54










  • and only the else statement is triggered
    – PHS
    Nov 14 at 6:59















0














I tried to write a script, that counts the e-Mails in a specific public exchange folder in outlook.
If there are Mails in subfolder2, a Messagebox should open and tell me, how many Mails there are. I tried this, but it did not work.



 Outlook := ComObjActive("Outlook.Application")
mail = (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("SubfolderSubfolder2")
if (mail.Items.Count>0)

msgbox % mail.Items.Count "Mails in folder"

else

msgbox No Mails.



Does anyone has a idea, how I should change the script, that it works?










share|improve this question























  • What does " it did not work" mean? Did you get an error?
    – Dmitry Streblechenko
    Nov 13 at 15:20










  • It does not count the mails in the folder i want. The Script works, no errors. Just not the way, i want it to work.
    – PHS
    Nov 14 at 6:54










  • and only the else statement is triggered
    – PHS
    Nov 14 at 6:59













0












0








0







I tried to write a script, that counts the e-Mails in a specific public exchange folder in outlook.
If there are Mails in subfolder2, a Messagebox should open and tell me, how many Mails there are. I tried this, but it did not work.



 Outlook := ComObjActive("Outlook.Application")
mail = (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("SubfolderSubfolder2")
if (mail.Items.Count>0)

msgbox % mail.Items.Count "Mails in folder"

else

msgbox No Mails.



Does anyone has a idea, how I should change the script, that it works?










share|improve this question















I tried to write a script, that counts the e-Mails in a specific public exchange folder in outlook.
If there are Mails in subfolder2, a Messagebox should open and tell me, how many Mails there are. I tried this, but it did not work.



 Outlook := ComObjActive("Outlook.Application")
mail = (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("SubfolderSubfolder2")
if (mail.Items.Count>0)

msgbox % mail.Items.Count "Mails in folder"

else

msgbox No Mails.



Does anyone has a idea, how I should change the script, that it works?







outlook autohotkey outlook-2016






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 at 11:56

























asked Nov 12 at 9:08









PHS

13




13











  • What does " it did not work" mean? Did you get an error?
    – Dmitry Streblechenko
    Nov 13 at 15:20










  • It does not count the mails in the folder i want. The Script works, no errors. Just not the way, i want it to work.
    – PHS
    Nov 14 at 6:54










  • and only the else statement is triggered
    – PHS
    Nov 14 at 6:59
















  • What does " it did not work" mean? Did you get an error?
    – Dmitry Streblechenko
    Nov 13 at 15:20










  • It does not count the mails in the folder i want. The Script works, no errors. Just not the way, i want it to work.
    – PHS
    Nov 14 at 6:54










  • and only the else statement is triggered
    – PHS
    Nov 14 at 6:59















What does " it did not work" mean? Did you get an error?
– Dmitry Streblechenko
Nov 13 at 15:20




What does " it did not work" mean? Did you get an error?
– Dmitry Streblechenko
Nov 13 at 15:20












It does not count the mails in the folder i want. The Script works, no errors. Just not the way, i want it to work.
– PHS
Nov 14 at 6:54




It does not count the mails in the folder i want. The Script works, no errors. Just not the way, i want it to work.
– PHS
Nov 14 at 6:54












and only the else statement is triggered
– PHS
Nov 14 at 6:59




and only the else statement is triggered
– PHS
Nov 14 at 6:59












3 Answers
3






active

oldest

votes


















0














Please try to use this:



mail := Outlook.ActiveExplorer().Session.GetDefaultFolder(18).Folders("SubfolderSubfolder2")






share|improve this answer




















  • sadly, it did not work. I still get the "else", although there are mails in the folder.
    – PHS
    Nov 14 at 14:47


















0














You must retrieve subfoldersone at a time, you cannot specify a path. Change the line



 mail = (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("SubfolderSubfolder2")


to



 mail = (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2")





share|improve this answer




















  • I still get the "No Mails" Message... I do not even know what folder the script accesses
    – PHS
    Nov 15 at 8:26










  • What does mail.Name return?
    – Dmitry Streblechenko
    Nov 15 at 14:09










  • an empty messagebox
    – PHS
    Nov 16 at 12:09










  • That would probably mean mail variable is null. I don't know how/if autohotkey handles COM exceptions, but apparently you are not accessing that folder correctly.
    – Dmitry Streblechenko
    Nov 16 at 14:57


















0














I got it.
I simply removed the Variable.



 Outlook := ComObjActive("Outlook.Application")
if (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2").Items.Count>0)

msgbox % Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2").Items.Count "Mails in folder"

else

msgbox No Mails.



Thanks for the help :D






share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53258901%2fcounting-mails-in-outlook-with-autohotkey%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Please try to use this:



    mail := Outlook.ActiveExplorer().Session.GetDefaultFolder(18).Folders("SubfolderSubfolder2")






    share|improve this answer




















    • sadly, it did not work. I still get the "else", although there are mails in the folder.
      – PHS
      Nov 14 at 14:47















    0














    Please try to use this:



    mail := Outlook.ActiveExplorer().Session.GetDefaultFolder(18).Folders("SubfolderSubfolder2")






    share|improve this answer




















    • sadly, it did not work. I still get the "else", although there are mails in the folder.
      – PHS
      Nov 14 at 14:47













    0












    0








    0






    Please try to use this:



    mail := Outlook.ActiveExplorer().Session.GetDefaultFolder(18).Folders("SubfolderSubfolder2")






    share|improve this answer












    Please try to use this:



    mail := Outlook.ActiveExplorer().Session.GetDefaultFolder(18).Folders("SubfolderSubfolder2")







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 14 at 7:23









    aifritz

    1




    1











    • sadly, it did not work. I still get the "else", although there are mails in the folder.
      – PHS
      Nov 14 at 14:47
















    • sadly, it did not work. I still get the "else", although there are mails in the folder.
      – PHS
      Nov 14 at 14:47















    sadly, it did not work. I still get the "else", although there are mails in the folder.
    – PHS
    Nov 14 at 14:47




    sadly, it did not work. I still get the "else", although there are mails in the folder.
    – PHS
    Nov 14 at 14:47













    0














    You must retrieve subfoldersone at a time, you cannot specify a path. Change the line



     mail = (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("SubfolderSubfolder2")


    to



     mail = (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2")





    share|improve this answer




















    • I still get the "No Mails" Message... I do not even know what folder the script accesses
      – PHS
      Nov 15 at 8:26










    • What does mail.Name return?
      – Dmitry Streblechenko
      Nov 15 at 14:09










    • an empty messagebox
      – PHS
      Nov 16 at 12:09










    • That would probably mean mail variable is null. I don't know how/if autohotkey handles COM exceptions, but apparently you are not accessing that folder correctly.
      – Dmitry Streblechenko
      Nov 16 at 14:57















    0














    You must retrieve subfoldersone at a time, you cannot specify a path. Change the line



     mail = (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("SubfolderSubfolder2")


    to



     mail = (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2")





    share|improve this answer




















    • I still get the "No Mails" Message... I do not even know what folder the script accesses
      – PHS
      Nov 15 at 8:26










    • What does mail.Name return?
      – Dmitry Streblechenko
      Nov 15 at 14:09










    • an empty messagebox
      – PHS
      Nov 16 at 12:09










    • That would probably mean mail variable is null. I don't know how/if autohotkey handles COM exceptions, but apparently you are not accessing that folder correctly.
      – Dmitry Streblechenko
      Nov 16 at 14:57













    0












    0








    0






    You must retrieve subfoldersone at a time, you cannot specify a path. Change the line



     mail = (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("SubfolderSubfolder2")


    to



     mail = (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2")





    share|improve this answer












    You must retrieve subfoldersone at a time, you cannot specify a path. Change the line



     mail = (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("SubfolderSubfolder2")


    to



     mail = (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2")






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 14 at 16:55









    Dmitry Streblechenko

    42.2k32760




    42.2k32760











    • I still get the "No Mails" Message... I do not even know what folder the script accesses
      – PHS
      Nov 15 at 8:26










    • What does mail.Name return?
      – Dmitry Streblechenko
      Nov 15 at 14:09










    • an empty messagebox
      – PHS
      Nov 16 at 12:09










    • That would probably mean mail variable is null. I don't know how/if autohotkey handles COM exceptions, but apparently you are not accessing that folder correctly.
      – Dmitry Streblechenko
      Nov 16 at 14:57
















    • I still get the "No Mails" Message... I do not even know what folder the script accesses
      – PHS
      Nov 15 at 8:26










    • What does mail.Name return?
      – Dmitry Streblechenko
      Nov 15 at 14:09










    • an empty messagebox
      – PHS
      Nov 16 at 12:09










    • That would probably mean mail variable is null. I don't know how/if autohotkey handles COM exceptions, but apparently you are not accessing that folder correctly.
      – Dmitry Streblechenko
      Nov 16 at 14:57















    I still get the "No Mails" Message... I do not even know what folder the script accesses
    – PHS
    Nov 15 at 8:26




    I still get the "No Mails" Message... I do not even know what folder the script accesses
    – PHS
    Nov 15 at 8:26












    What does mail.Name return?
    – Dmitry Streblechenko
    Nov 15 at 14:09




    What does mail.Name return?
    – Dmitry Streblechenko
    Nov 15 at 14:09












    an empty messagebox
    – PHS
    Nov 16 at 12:09




    an empty messagebox
    – PHS
    Nov 16 at 12:09












    That would probably mean mail variable is null. I don't know how/if autohotkey handles COM exceptions, but apparently you are not accessing that folder correctly.
    – Dmitry Streblechenko
    Nov 16 at 14:57




    That would probably mean mail variable is null. I don't know how/if autohotkey handles COM exceptions, but apparently you are not accessing that folder correctly.
    – Dmitry Streblechenko
    Nov 16 at 14:57











    0














    I got it.
    I simply removed the Variable.



     Outlook := ComObjActive("Outlook.Application")
    if (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2").Items.Count>0)

    msgbox % Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2").Items.Count "Mails in folder"

    else

    msgbox No Mails.



    Thanks for the help :D






    share|improve this answer

























      0














      I got it.
      I simply removed the Variable.



       Outlook := ComObjActive("Outlook.Application")
      if (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2").Items.Count>0)

      msgbox % Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2").Items.Count "Mails in folder"

      else

      msgbox No Mails.



      Thanks for the help :D






      share|improve this answer























        0












        0








        0






        I got it.
        I simply removed the Variable.



         Outlook := ComObjActive("Outlook.Application")
        if (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2").Items.Count>0)

        msgbox % Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2").Items.Count "Mails in folder"

        else

        msgbox No Mails.



        Thanks for the help :D






        share|improve this answer












        I got it.
        I simply removed the Variable.



         Outlook := ComObjActive("Outlook.Application")
        if (Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2").Items.Count>0)

        msgbox % Outlook.Application.ActiveExplorer().Session.GetDefaultFolder(18).Folders("Subfolder").Folders("Subfolder2").Items.Count "Mails in folder"

        else

        msgbox No Mails.



        Thanks for the help :D







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 21 at 14:25









        PHS

        13




        13



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53258901%2fcounting-mails-in-outlook-with-autohotkey%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3

            Museum of Modern and Contemporary Art of Trento and Rovereto