Applescript download ip cam image, attach and send via email

Posted on
Mon Jan 28, 2013 11:02 pm
whmoorejr offline
User avatar
Posts: 763
Joined: Jan 15, 2013
Location: Houston, TX

Applescript download ip cam image, attach and send via email

Hacked this together from several other websites and a couple tid-bits from this one. So far it is working. The camera (btw) is a panasonic BB-
HCM311A

Code: Select all
set {tUrl, dFolder} to {"http://10.0.6.253/SnapshotJPEG?Resolution=640x480/1.jpg ", "~/Desktop/IPCam/"}

set {oAStid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
set fName to (last text item of tUrl) as string
set AppleScript's text item delimiters to oAStid

do shell script ("mkdir -p " & dFolder & "; curl -A/--user-agent " & tUrl & " >> " & (dFolder & fName))

set theAttachment1 to POSIX file "/Users/service/Desktop/IPCam/1.jpg"

tell application "Mail"
   set newMessage to make new outgoing message with properties {subject:"Motion Received", content:"Attached Image" & return & return}
   tell newMessage
      
      set visible to false
      set sender to "email_a@gmx.com"
      make new to recipient at end of to recipients with properties {address:"email_b@gmail.com, email_c@gmail.com"}
      make new attachment with properties {file name:theAttachment1} at after the last paragraph
      
      (* change save to send to send*)
      send --<<<<---------------- change save to send to send
      (* change save to send to send*)
      
   end tell
end tell
delay 2
tell application "Finder"
   delete folder "IPCam"
end tell


it creates a temporary folder on the desktop and saves the current net cam image. At the end of the script it deletes the folder.

Bill
My Plugin: My People

Posted on
Tue Jan 29, 2013 3:10 am
durosity offline
User avatar
Posts: 4320
Joined: May 10, 2012
Location: Newcastle Upon Tyne, Ye Ol' England.

Re: Applescript download ip cam image, attach and send via e

Nice.. I’m about to install a front door cam and wanted something like that for if someone presses the door bell and i’m away from home!

Computer says no.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 16 guests