Announcement

Collapse
No announcement yet.

How can I determine when a message has been left?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How can I determine when a message has been left?

    I've been playing around with the VR Answering Machine Script (thanks dwoolridge!) this weekend. I setup the boxes for the family members so that we can leave message for each other as our busy lives cross paths. What I want to be able to do is to check each mailbox periodically to see if there are any new messages. Then I can do something to alert tht person that s/he has new messages. Can't figure out how to do this. Can somebody get me pointed in the right direction before my wife realizes that I have nothing better to do?

    #2
    Basically you'd need to call hsp.MBFirstUnreadMessage (after setting up the mailbox and line parameters and sorting) for each mailbox to see if it returns something other than a null filename - if it does, there are unread messages (and therefore you can consider them "new").

    - Gordon

    Did they really change the Star Trek motto under Jean-Luc Picard's command to, "To Baldly Go Where No Man's Hair's Gone Before!" ???

    "Don't look under the hat."
    - Gordon, 2004
    |
    | - Gordon

    "I'm a Man, but I can change, if I have to, I guess." - Man's Prayer, Possum Lodge, The Red Green Show
    HiddenGemStudio.com - MaineMusicians.org - CunninghamCreativeMaine.website

    Comment


      #3
      With a little bit of adjustment you should be able to use this. I only use one mailbox but this code will iterate through all the defined mailboxes.
      <pre class="ip-ubbcode-code-pre">
      c = 0
      For i = 1 To hsp.ADRCount - 1
      Set mb = hsp.MBGet(i)
      mbmsg = hsp.MBFirstUnreadMessage(1, mb)
      While mbmsg &lt;&gt; ""
      mbmsg = hsp.MBNextUnreadMessage(1, mb)
      c = c + 1
      Wend
      if c &gt; 0 then
      links = links & "&lt;img src=""new_messages.gif"" border=""0""&gt;"
      end if
      Set mb = Nothing
      Next
      </pre>

      -Rupp
      💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

      Comment


        #4
        Wouldn't the Mailbox Class be easier? There are a bunch of properties including one called unread_messages.

        Joe
        HomeSeer Rocks!

        Comment


          #5
          I tried your code by pasting into a text file and adding the sub main() and end sub, which I assume I need. But when I test the script HS ends up exectuing the script forever. If I comment out the "next" it errors out. What am I missing?

          Comment


            #6
            That looks like a way to accomplish things, but how does one use the mailbox class properties? I've looked all through the help files and don't see any syntax for that. BTW, I'm just down the road a piece in Batavia.

            Comment


              #7
              Assuming you have a mailbox named Mark:

              'get a reference to the mailbox class
              set mb=hsp.MBGetByName("Mark")

              'get the collection of messages for the mailbox
              set msgs = mb.messages

              'get count of unread messages for the collection
              unreadmsgs = msgs.unread_messages

              Does this help?

              We’ve got the tri-city area covered between you, me, and GenevaDude. You should come to the next CHAUG meeting which is the first Wednesday of next month. Shoot me and email if you like.

              Joe
              HomeSeer Rocks!

              Comment


                #8
                When I try the unread_messages, I get the following error in my log:

                424:Object required: 'msgs' in line 13

                I have got a small script working using an ini file and doing some math, but it will be way more wife friednly to get this method working.

                Yeah, I need to get to one of those meetings sometime. If I am not out of town (tentative today), maybe I'll hit the March meeting. I wouldn't have to shoot you AND email you would I?

                Comment


                  #9
                  I needed mb.unread_messages.

                  Comment


                    #10
                    <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR> Mark writes:
                    I wouldn't have to shoot you AND email you would I? <HR></BLOCKQUOTE>

                    Oops...lol...I can do without the shot unless it's of alcohol.

                    <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>Mark writes:
                    I needed mb.unread_messages <HR></BLOCKQUOTE>

                    Are you saying that:

                    set mb=hsp.MBGetByName("Mark")
                    unreadmsgs = mb.unread_messages

                    is all you need to get the count and that you don't need to reference it from the messages collection?

                    I want to understand how this works so I don't lead anyone else astray.

                    Joe
                    HomeSeer Rocks!

                    Comment


                      #11
                      Here is what I have so far (it's not quite done)

                      sub main()

                      dim mb
                      dim messages
                      dim count
                      dim old_messages
                      dim new_messages


                      set mb=hsp.MBGetByName("Barb") ' get Barb's mailbox
                      set messages = mb.messages ' get the collection of messages
                      count = messages.count ' get the total number of messages
                      unreadmsgs = mb.unread_messages

                      old_messages = hs.GetIniSetting("Barb","Number_of_messages",0,"Phone_Messag e_Count.ini")
                      new_messages = CInt(count)-CInt(old_messages)

                      '*********************************************************** *****************************************
                      ' Set the reminder flag to ON if either new messages are found or the message count increases
                      '
                      '*********************************************************** *****************************************

                      if CInt(new_messages)&gt;0 then
                      hs.SetDeviceStatus "M20", 2
                      end if

                      If CInt(unreadmsgs) &gt; 0 then
                      hs.SetDeviceStatus "M20", 2
                      end if

                      '*********************************************************** *****************************************
                      ' Set the reminder flag to OFF if no new messages are present. This will set the message
                      ' to unmarked if played via the PC. If played via ACE the reminder will be shut off by an
                      ' event.
                      '
                      '*********************************************************** *****************************************

                      If CInt(unreadmsgs) = 0 then 'turn the reminder off if no new messages
                      hs.SetDeviceStatus "M20", 3
                      end if

                      '*********************************************************** *****************************************
                      ' Reset the ini file to the current number of messages
                      '
                      '*********************************************************** *****************************************

                      hs.SaveINISetting "Barb","Number_of_messages",count,"Phone_Message_Count.i ni"


                      end sub

                      What I have in here so far is working. What I want to do is to set m20 "on" whenever there is a new message for Barb. I haven't fully decided if I'll really need the ini file or not. When all is said and done I just need to be sure that whether my wife listens to messages over the phone, on the PC or via X10 commands that everything works one way (at least to the user).

                      Comment


                        #12
                        I don't think you need the ini file either. Unless I'm missing something (which wouldn't surprise me) I think the following should be equal to what you posted since new messages is the same as unread messages. I don't know what the Ace does though so like I said I might be off base.

                        sub main()

                        dim mb
                        dim new_messages

                        set mb=hsp.MBGetByName("Barb") ' get Barb's mailbox
                        new_messages = mb.unread_messages

                        '*******************************************************
                        ' Set the reminder flag to ON if new messages are found
                        ' else turn the flag OFF
                        '*******************************************************

                        if CInt(new_messages)&gt;0 then
                        hs.SetDeviceStatus "M20", 2
                        else
                        hs.SetDeviceStatus "M20", 3
                        end if

                        end sub

                        Joe
                        HomeSeer Rocks!

                        Comment


                          #13
                          In all of the posted code above, I don't see a single call to hsp.MBSort, which, according to the HSP documentation, should be called at least once before calling hsp.MBGet. The MBSort call updates the mailbox status and sorts voicemails by date. In my web ASP pages, not calling MBSort produced unpredictable results.

                          - Gordon

                          Did they really change the Star Trek motto under Jean-Luc Picard's command to, "To Baldly Go Where No Man's Hair's Gone Before!" ???

                          "Don't look under the hat."
                          - Gordon, 2004
                          |
                          | - Gordon

                          "I'm a Man, but I can change, if I have to, I guess." - Man's Prayer, Possum Lodge, The Red Green Show
                          HiddenGemStudio.com - MaineMusicians.org - CunninghamCreativeMaine.website

                          Comment


                            #14
                            After I gave the "ini method" more thought I came to the same conclusion. Not only not needed, but would end up being pretty convoluted.

                            Gordon- Thanks for the sort tip, I'll put that in place.

                            Comment

                            Working...
                            X