No announcement yet.

[Script][Asp] Pollen report parsed from daily email

  • Filter
  • Time
  • Show
Clear All
new posts

    [Script][Asp] Pollen report parsed from daily email

    I made a *really* simple script to parse the daily email messages I signed up for from
    I then put the pollen count and types in a device string. I then use this on my web page and for a morning weather report.

    I use the second script as a function in my morning (spoken) weather reports. It will strip off all the HTML crap so it sounds correct.

    I call it like this:
    <pre class="ip-ubbcode-code-pre">system.speak "The Pollen for today is " & FixPollen(hs.DeviceString(Pollen))</pre>
    I made this as I was using the AirQuality script, but it broke due to recent changes on their web page.

    <LI>1&gt; Sign up for daily email alerts at, also find the correct link to your local forecasts.
    <LI>2&gt; Insert the first part of this script into whatever script you use to parse inbound mail. If you don't have one, you will need to setup an event triggered on inbound email, then put this script in the script box, you will need to put a "Sub Main()" in the front and an "End Sub" at the end.
    <LI>3&gt; Change the variables PollenDevice and Pollenlink to match your system, also replace the 'CA:' where indicated.[/list]

    First Script (insert into inbound email script)
    <pre class="ip-ubbcode-code-pre">
    Msgindex = hs.MailTrigger 'remove if these already exist in your script
    MsgSubject = hs.MailSubject(MsgIndex) 'remove if these already exist in your script
    MsgFrom = hs.MailFrom(MsgIndex) 'remove if these already exist in your script
    MsgText = hs.MailText(MsgIndex) 'remove if these already exist in your script

    ' ************************************************************ ******************
    ' ************* Pollen Alert Parser - Sign up for daily alerts at
    '* Change PollenLink and PollenDevice to match your system
    ' ************************************************************ ******************
    if instr(ucase(MsgSubject),"ALLERGY") then
    t1 = instr(ucase(MsgText),"CA:") '** Change the CA: to your state ***
    Tmp = mid(msgtext,t1+5,255)
    t1 = instr(Tmp,vbNewLine)
    Tmp2 = mid(tmp,1,t1)

    PollenLink = "&lt;a href='' target='_blank'&gt;"
    PollenDevice = "q10"

    if instr(ucase(tmp2),"HIGH") then
    tmp2 = replace(tmp2,"High",PollenLink & "&lt;font color=red&gt;&lt;b&gt;High&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;",1,-1,1)
    elseif instr(ucase(tmp2),"MEDIUM") then
    tmp2 = replace(tmp2,"Medium",PollenLink & "&lt;font color=yellow&gt;&lt;b&gt;Medium&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;",1,-1,1)
    elseif instr(ucase(tmp2),"LOW") then
    tmp2 = replace(tmp2,"Low",PollenLink & "&lt;font color=green&gt;&lt;b&gt;Low&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;",1,-1,1)
    end if

    t1 = instr(ucase(tmp),"POLLEN:")
    Tmp3 = mid(tmp,t1+9,100)
    t2 = instr(Tmp3,vbNewLine)
    Tmp3 = mid(tmp3,1,t2)

    hs.setdeviceLastChange PollenDevice, now
    hs.setdevicestring PollenDevice, tmp2 & "&lt;br&gt;" & tmp3
    ' hs. writelog "Pollen", "Pollen Alert Received: " & tmp2 & tmp3
    end if

    Second Script/function:
    <pre class="ip-ubbcode-code-pre">
    Function FixPollen(Text)
    Text = replace(text,"&lt;br&gt;"," ")
    Text = replace(text,"&lt;a href='' target='_blank'&gt;","")
    Text = replace(text,"&lt;font color=red&gt;&lt;b&gt;High&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;"," High ")
    Text = replace(text,"&lt;font color=yellow&gt;&lt;b&gt;Medium&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;"," Medium ")
    Text = replace(text,"&lt;font color=green&gt;&lt;b&gt;Low&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;"," Low ")
    FixPollen = Text
    End Function