X10 Community Forum

🖥️ActiveHome Pro => Smart Macros => Plug-ins => User-Designed Working Macros => Topic started by: RebHawk on March 09, 2008, 08:44:01 PM

Title: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: RebHawk on March 09, 2008, 08:44:01 PM
This seemed like the best place to put this.  If not, feel free to move it to the correct place.

Narrative:

Despite the help of those here, I have never been able to get email from MyHouseOnline or any other AHP email to work.  I tried to get it working for some time, but finally gave up and decided to send my email using VBScripts run by batch files which are in turn run by using a PC Command from AHP in my AHP macro.  An example would be my Den Door macro.  If I have my "ARMED AWAY" flag set and the den door DS10A is tripped, the macro sounds my power horns and emails me at my home account, office account, and cell phone.  My powerhorns are triggered by a powerflash module that is in turn triggered by a universal module.

Trigger Conditions:
ARMED AWAY Flag set (NOTE: NOT the same as OnAlert ARMED AWAY.  I use one of the 16 AHP Flags for this function)
Den Door DS10A tripped


Actions:

Powerhorns ON
Delay 2 seconds
Execute Windows Program:
     c:\wtmp\X10\email\Den-Door.bat

This batch file simply contains the line:
     c:\wtmp\X10\email\Den-Door.vbs

This batch file runs the following VBScript, which actually sends the email:

Set objEmail = CreateObject("CDO.Message")
objEmail.From = "xxx@xxx.com"
objEmail.To = "xxx@xxx.com, yyy@yyy.edu, ##########@vtext.com"
objEmail.Subject = "ALERT ALERT ALERT Den Door Open"
objEmail.Textbody = "DEN DOOR OPENED!!!"
objEmail.Send


The above VBScript is saved with a name like "Den-Door.vbs" as indicated above.

You can cut and paste the above macro, replacing xxx, yyy, and #### as necessary for your particular email addresses and/or cell phone text message addresses.  Then build a library of bat/vbs files, one pair for each particular email alert you wish to send.  The advantage of this method is that it doesn't rely at all on AHP, except for running the batch file, which AHP seems to have no problem doing.

One caveat, make CERTAIN you have word wrap turned OFF in your text editor when writing these vbs files.  The line most likely to get word-wrapped is the "objEmail.To =" line, so if you get an error when trying to run the scripts, make sure you don't have a word wrap problem.

Another advantage to this method is that you can do all your testing outside of AHP.  Simply go to the directory you have these files stored in and double-click the batch file.  Edit and repeat until you get it working (which shouldn't take long!).

To me this method is much more robust than the AHP methods. 

Regards,
--Lee

EDIT: Fixed typo in trigger command name (should be Den-Door.bat, not Den-Door.vbs)
EDIT: Clarified some details of the file names for the various scripts.
Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: jtykal on March 09, 2008, 11:09:25 PM
Lee -- I've been planning to do something like this when I had a few cycles to spare. Thanks for saving me the time with this very helpful script! Can't wait to try it out!
Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: RebHawk on March 09, 2008, 11:07:12 PM
Glad I could help.  Note the correction I made to the trigger command.  Should have referred to the .bat file, not the .vbs file.  Also, for those not familiar with VBScript, it is built-in to Windows.  No need for extra software :D

Cheers,
--Lee
Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: KDR on March 10, 2008, 06:03:00 AM
Nice tip RedHawk, a  good alternative to get that email sent out. Gets a helpful from me.

(http://www.bdshost.com/X10/lpup.gif)---(http://www.bdshost.com/X10/lpup.gif)---(http://www.bdshost.com/X10/lpup.gif)---(http://www.bdshost.com/X10/lpup.gif)---(http://www.bdshost.com/X10/lpup.gif)----KDR
Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: chuck on March 10, 2008, 11:26:19 AM
Thanks.  I've used this code before, but was so hell-bent on making AHP email work I forgot about using it.  I tried it out and even dug out some old code I had, but it appears my new ISP (Verizon FIOS) blocks this kind of traffic.

I googled  "CreateObject("CDO.Message")" and found a very helpful site <<http://www.paulsadowski.com/WSH/cdo.htm>>  Here they have code for dealing with using your ISP's mail server passing it a username and password.  You will need to know your outgoing mail server info (same info you need to setup a mail client.

I hope this helps others in my situation.  I also hope the AHP developers will update their software to allow for email server configuration.
Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: Tuicemen on March 10, 2008, 04:19:13 PM
RebHawk  And chuck
You both get a helpful from me as many users will have to put both bits together to send!

RebHawk this Is the correct place for user created Macros! As jtykal pointed out
Quote
Thanks for saving me the time.....
this macro library is designed to save users time creating similar macros!
Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: chuck on March 18, 2008, 02:27:16 PM
Follow up question to the use of these macros and executing windows programs...  I realize the computer must be running in order for the macros to execute the programs on the computer, but does a users have to be logged into the machine and AHP GUI actively running, or does/can the AHP service execute these programs -- without the GUI?

I have AHP running on a Win2K server (who's primary function is my family web server).  Typically, no one is ever logged into the machine b/c everything has been running as a service.  However, I will have to change this model if AHP GUI client needs to be running on the console.

Please advise.
Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: Tuicemen on March 18, 2008, 02:49:55 PM
In order for the batch files to execute AHP need be running so looks like you'll need to reconfigure your Win2k machine! ;)
Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: halcali on April 25, 2009, 05:13:27 AM
has anyone been able to get this code to work with gmail smtp?

i tried the following code and it didn't work.

----------------------------------------------------

Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM


Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "ALERT ALERT ALERT Den Door Open"
objMessage.From = "xxx@xxx.com"
objMessage.To = "xxx@xxx.com"
objMessage.Textbody = "DEN DOOR OPENED!!!"

'==This section provides the configuration information for the remote SMTP server.

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "yourusername@gmail.com"

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465



'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send

---------------------------------------------------------------


what did i mess up?
Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: me too on April 25, 2009, 10:39:53 PM
The below works for me everytime. 



Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Sent because x10 event happened " & Now()
objMessage.From = "emailaddress"
objMessage.To = "emailaddress"
objMessage.TextBody = "Someone by the front door " & Now()


'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "your server address"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send
strSoundFile = "C:\Windows\Media\Notify.wav"
Set objShell = CreateObject("Wscript.Shell")
strCommand = "sndrec32 /play /close " & chr(34) & strSoundFile & chr(34)
objShell.Run strCommand, 0, True


Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: JMac on August 13, 2010, 12:34:17 AM
I had been using VBS (and yahoo) for quite a while with no problems.  Then I realized that messages would take as long as 45 - 50 minutes before completion.  I switched to "gmail" setup and the message completion only took a few seconds.  Anybody know how come ?
Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: Noam on August 13, 2010, 10:16:35 AM
I have found that Yahoo mail can be slow (especially in the last few months) for no apparent reason.
Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: JMac on August 13, 2010, 10:28:07 AM
Thanks, Noam.  For awhile I thought I was going to have to dig deeper into my setup to locate the problem.
Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: pconroy on August 13, 2010, 10:59:25 AM
I have found that Yahoo mail can be slow (especially in the last few months) for no apparent reason.

i don't want to kick a company when it's down - but a few of the other Yahoo services I still use - like their groups - appears to have slid downhill dramatically.

Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: Noam on August 13, 2010, 12:39:33 PM
I'm happy to keep kicking - let them fight back (fix the problems)!

They BROKE Blackberry synchronization for nearly two months earlier this summer.
They BROKE my calendar (by "upgrading" it to the new Beta calendar), so it can no longer sync with my Blackberry.

I've been using them as my primary e-mail address for over 10 years, so it is really hard for me to just dump them.
Title: Re: [TIP] Alternate Email Method If MyHouseOnline Email Won't Work For You
Post by: jayman13 on July 04, 2011, 11:09:11 AM
Just wanted to post my script that worked as it may help someone trying to figure this out.  FYI I have comcast so I used the smtp comcast server which required my comcast user name and password but could be used with any provider I'm sure:

 Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
 Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
 
 Const cdoAnonymous = 0 'Do not authenticate
 Const cdoBasic = 1 'basic (clear-text) authentication
 Const cdoNTLM = 2 'NTLM
 
 Set objMessage = CreateObject("CDO.Message")
 objMessage.Subject = "Office Light On"
 objMessage.From = """ASrock3"" <yourname@comcast.net>"
 objMessage.To = "desiredemail@gmail.com"
 objMessage.TextBody = "Office Light On!"
 
 '==This section provides the configuration information for the remote SMTP server.
 
 objMessage.Configuration.Fields.Item _
 ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
 
 'Name or IP of Remote SMTP Server
 objMessage.Configuration.Fields.Item _
 ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.comcast.net"
 
 'Type of authentication, NONE, Basic (Base64 encoded), NTLM
 objMessage.Configuration.Fields.Item _
 ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
 
 'Your UserID on the SMTP server
 objMessage.Configuration.Fields.Item _
  ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "yourname@comcast.net"
 
 'Your password on the SMTP server
 objMessage.Configuration.Fields.Item _
 ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"
 
 'Server port (typically 25)
 objMessage.Configuration.Fields.Item _
 ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  
 'Use SSL for the connection (False or True)
 objMessage.Configuration.Fields.Item _
 ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
 
 'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP   server)
 objMessage.Configuration.Fields.Item _
 ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
 
 objMessage.Configuration.Fields.Update
 
 '==End remote SMTP server configuration section==  
 
 objMessage.Send