Announcement

Collapse
No announcement yet.

Script to Parse Content on Email

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

    Script to Parse Content on Email

    Is there already a script out that will parse through an incoming email and trigger event based on keywords? I use JON00's pop3 email checker and I know a subject line can trigger an event, But I need something that can trigger of the content of the email? Any Ideas?

    #2
    I too would be extremely interessted if there was a way I could check the content of an email for certain Keywordsa and trigger events based on the existence of these words.
    jjsmd@yahoo.com

    Comment


      #3
      A search turned up this thread that should get you started - http://board.homeseer.com/showthread.php?t=98346

      Comment


        #4
        Hi I already had that. I have been in PM discussions with Rupp, Jon00, and MLOEBL they have been all very helpful. Right now I am trying to get it to parse usin Jon00's checkemail pop V3. His plugin is very nice and the scripting he setup already has alot of email checking features. Plus I like that it checks the server without relying on Outlook for email.

        Comment


          #5
          Here's a quicky that I just put together. Simply change the 2 CONST in the top to your email addy and event name and wait for an email.

          ' This script will access the email message that caused this event to trigger
          ' it will then run the event in the subject if the from address matches.
          '
          Code:
          CONST cEventName = "What is the date"
          CONST cEmailAddress = "yourEmailAddress.com"
          
          sub main()
          
          	index = hs.MailTrigger
          	sMailFrom = hs.MailFrom(index)
          	sSubject = hs.MailSubject(index)
          	sStatus = fParseMail(sMailFrom, sSubject)
          	hs.writelog "email_parser", sStatus
          	
          end sub
          
          function fParseMail(sMailFrom, sSubject)
            
              if lcase(sMailFrom) = lcase(cEmailAddress) then
          	if instr(1,lcase(sSubject),lcase(cSearchString)) > 0 then
          		fParseMail = "Success"
          		hs.triggerEvent(cEventName)
          	else
          		fParseMail = "Failed"
          	end if
              end if
          
          
          end function
          -Rupp
          sigpic

          Comment


            #6
            I'll give it a whirl...

            Comment


              #7
              Originally posted by pp
              I'll give it a whirl...
              Let me know. I found an error in the other one I posted for you so this should work.
              -Rupp
              sigpic

              Comment


                #8
                Ding Ding Ding We got a winner!
                Seemed to work fine. GOing to try a few more but I think that's it..
                Thank YOUUUUUUUUUUUUUUUUU!

                Comment


                  #9
                  Spoke too soon. hehe
                  Strangest thing, once I triggered it once I can no longer get it too work. I didnt change the script setting and it will run the script with no errors but It always ends with a fail. I am going to delete and retry everything. Any thoughts?

                  Comment


                    #10
                    Where do I add the keyword to search with in the message body?
                    The word it will parse through in the message? Not the subject line.

                    ' This script will access the email message that caused this event to trigger
                    ' it will then run the event in the subject if the from address matches.
                    '
                    Code:
                    CONST cEventName = "What is the date"
                    CONST cEmailAddress = "yourEmailAddress.com"
                    
                    sub main()
                    
                    	index = hs.MailTrigger
                    	sMailFrom = hs.MailFrom(index)
                    	sSubject = hs.MailSubject(index)
                    	sStatus = fParseMail(sMailFrom, sSubject)
                    	hs.writelog "email_parser", sStatus
                    	
                    end sub
                    
                    function fParseMail(sMailFrom, sSubject)
                      
                        if lcase(sMailFrom) = lcase(cEmailAddress) then
                    	if instr(1,lcase(sSubject),lcase(cSearchString)) > 0 then
                    		fParseMail = "Success"
                    		hs.triggerEvent(cEventName)
                    	else
                    		fParseMail = "Failed"
                    	end if
                        end if
                    
                    
                    end function
                    [/QUOTE]

                    Comment


                      #11
                      The script is only parsing the subject. It will also only work when an actual email is received and not when manually triggered because of the way HomeSeer parses email.
                      -Rupp
                      sigpic

                      Comment


                        #12
                        I dont need to parse the subject but the message body.. Can that be done?

                        Comment


                          #13
                          Try this. I didn't get to test it because I'm away from my pc.

                          Code:
                          CONST cEventName = "What is the date"
                          CONST cEmailAddress = "yourEmailAddress.com"
                          CONST cSearchString = "This is a test"
                          
                          sub main()
                          
                          	index = hs.MailTrigger
                          	sMailFrom = hs.MailFrom(index)
                          	sSubject = hs.MailSubject(index)
                                       sBody = hs.MailText(index)
                          	sStatus = fParseMail(sMailFrom, sBody)
                          	hs.writelog "email_parser", sStatus
                          	
                          end sub
                          
                          function fParseMail(sMailFrom, sBody)
                            
                              if lcase(sMailFrom) = lcase(cEmailAddress) then
                          	if instr(1,lcase(sBody),lcase(cSearchString)) > 0 then
                          		fParseMail = "Success"
                          		hs.triggerEvent(cEventName)
                          	else
                          		fParseMail = "Failed"
                          	end if
                              end if
                          
                          
                          end function
                          Last edited by Rupp; December 18, 2006, 12:47 PM.
                          -Rupp
                          sigpic

                          Comment


                            #14
                            where do I put in the Keyword? to be searched?

                            Comment


                              #15
                              Duh! Let me add that as I was still thinking event. Sorry
                              -Rupp
                              sigpic

                              Comment

                              Working...
                              X