Sub Main()
Dim i, line, adr_count, contact
Dim callname, callnmbr, dhit, addbk
Dim TOaddress, TOaddress2, FROMaddress, subject, body
Dim CallTime, CallDate, CallDate2, CallDay, CallWeekday, CallMonth, CallYear
CallTime=TimeValue(FormatDateTime(Now,3))
CallDate=weekdayname(weekday(date))
CallDate2=Date
CallDay=Day(DatePart("d",date))
CallWeekday=WeekDayName(DatePart("w",date))
CallMonth=MonthName(DatePart("m",date))
CallYear=DatePart("yyyy",date)
callname = hsp.cidname(1) ' get the caller directory name
callnmbr = hsp.cidnumber(1) ' get the phone number
if callnmbr = "O" then
callnmbr = "*Out of Area"
end if
if callnmbr= "P" then
callnmbr = "*Private"
end if
dhit = False ' init the directory hit flag
adr_count = hsp.ADRCount ' number of address book entries
if instr(1,callname,",") Then ' reverse if last, first format
callname = trim(hs.stringItem(callname,2,",")&" "&hs.stringItem(callname,1,","))
end if
if left(callnmbr,1) <> "*" then
if instr(1,callnmbr,"-") = 0 Then 'Is it a CID message, skip formatting
callnmbr = trim(callnmbr) 'Are the dashes missing?
callnmbr = left(callnmbr,3)&"-"&mid(callnmbr,4,3)&"-"&right(callnmbr,4) 'format it for voice if dashes are missing
end if
end if
for i = 1 to adr_count ' look thru address book for number
set contact = hsp.ADRGet(i) ' get the reference to the addrbk entry
select case callnmbr ' see if the number is in the book
case contact.home_phone
callname = contact.first&" "&contact.last ' pickup the name
addbk = "Home number" ' denote the source
dhit = true ' we had a hit in the address book
exit for ' performance - exit loop if found
case contact.cell_phone
callname = contact.first&" "&contact.last
addbk = "Cell number"
dhit = true
exit for
case contact.business_phone
callname = contact.first&" "&contact.last
addbk = "Work number"
dhit = true
exit for
end select
next
Const None = 0, Info = 1, Alert = 2, Error = 3
'update device strings
hs.setDeviceString "r3", callname 'CIDName
hs.setDeviceString "r4", callnmbr 'CIDNumber
hs.setDeviceString "r5", CallTime 'CIDTime
hs.setDeviceString "q80", callname & ": " &callnmbr & " at " & CallTime 'CID String
'send to MLCID
hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLCallerID|SendCID:" &callname & "~" &callnmbr
'send an email
TOaddress = "[email protected]"
TOaddress2 = "[email protected]"
FROMaddress = "[email protected]"
subject = "New Caller ID from: " &callnmbr &"."
body="There was a phonecall at " &CallTime &", " &CallDate &", " &CallMonth &" " &CallDay &" " &CallYear &", from " &callname &", "&callnmbr &" which is a "&addbk &"." &" The existence of new caller ID information does not necessarily mean a message was left, however to remotely check your messages: (1) Call home with a touch-tone phone. (2) During the outgoing message, press 'secretcode'. The answering maching will then announce the number of messages stored in memory and issue voice promptes for additional commands. (3) To quit, hang up the phone. //// To turn the answering system on remotely: (1) Call your phone and let it ring 10 times until you here a beep. (2) Press 'secretcode'. (3) Press '05' to stop the announcement. (4) Press '06' to turn the answering system on. /// The following keys are used to control message playback: '01'-Repeat message; '02'-Play incoming messages; '03'-Skip message; '04'-Delete message; '05'-Stop operation; '06'-Answering system on; '07'-Memo record/stop; '08'-Greeting message record/stop; '09'-Answering system off; '10'-Help. /// Thank you, /// HACI - end of message"
hs.SendEmail TOaddress, FROMaddress, subject, body
hs.SendEmail TOaddress2, FROMaddress, subject, body
End Sub