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?
Announcement
Collapse
No announcement yet.
How can I determine when a message has been left?
Collapse
X
-
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
-
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 <> ""
mbmsg = hsp.MBNextUnreadMessage(1, mb)
c = c + 1
Wend
if c > 0 then
links = links & "<img src=""new_messages.gif"" border=""0"">"
end if
Set mb = Nothing
Next
</pre>
-Rupp
Comment
-
jhisr
Wouldn't the Mailbox Class be easier? There are a bunch of properties including one called unread_messages.
Joe
HomeSeer Rocks!
Comment
-
jhisr
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
-
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
-
jhisr
<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
-
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)>0 then
hs.SetDeviceStatus "M20", 2
end if
If CInt(unreadmsgs) > 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
-
jhisr
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)>0 then
hs.SetDeviceStatus "M20", 2
else
hs.SetDeviceStatus "M20", 3
end if
end sub
Joe
HomeSeer Rocks!
Comment
-
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
Comment