Page 1 of 25 12311 ... LastLast
Results 1 to 10 of 250

Thread: Emailing Script

  1. #1
    Join Date
    Nov 2003
    Location
    Hove, E Sussex, UK
    Posts
    4,005

    Default Emailing Script

    Hi,

    This is a bit of code I have put together for sending email status reports to any given address.

    I thought I would post it so that others may use it or adapt as reqd.

    Code:
    require("socket\\smtp")
    socket.smtp.SERVER = "smtp.your server.com";
    email = {
    
    SendEmailMsg = function (self, msgtext, msgsubject, msgtype)
    local r, e
    
    self.msg = {
    	headers = {
    		from = "Girder Status Reports",
    		to = "Tony Blair",
    		subject = msgsubject or "Vote for me!..."
    		},
    	body = msgtext or ""	
    	}
    self.from = "<girder@No10.com>"	
    
    if msgtext then self.msg.body = msgtext end;
    self.msg.body = "Automatically Generated System Report\n\n"..self.msg.body.."\n\nReport Compiled & Sent on "..os.date&#40;&#41;
    r, e = socket.smtp.send&#123;
      from = self.from,
      rcpt = self.to, 
      source = socket.smtp.message&#40;email.msg&#41;
    &#125;
    
    if r == 1 then
    	gir.LogMessage &#40;"Email Status","Status Msg sent successfully - "..&#40;msgtype or ""&#41;&#41;
    else
    	gir.LogMessage &#40;"Email Status","Status Msg failed, err&#58; "..e&#41;
    end;	
    
    end;
    &#125;
    
    email.to = &#123;
    	"<Tony@No10.com>",
    	"<Fred@the canary.com>",
    	&#125;
    
    email&#58;SendEmailMsg &#40;"Girder is working!\n\nGirder Started", "Girder Started", "Status"&#41;;
    Basically you call it using the following.

    Code:
    email&#58;SendEmailMsg &#40;&#91;Message Test&#93;, &#91;Message Subject&#93;, &#91;Message Type&#93;&#41;;
    Message Type is used for indication in the logger.

    Edit all the address as suits you. also put in your server etc.
    Thx, Dan

    Onwards and Upwards!
    http://www.danward.co.uk

  2. #2
    Join Date
    Dec 2001
    Posts
    11,560

    Default

    nice

  3. #3
    Join Date
    Jul 2001
    Location
    Risør - Norway
    Posts
    5,477

    Default

    Very nice! Did Tony answer you?
    Tor - managing director of the Cinema Inferno home theater and multi-zone sound system with Girder running the show in the back, NetRemote as the GUI and Media Center 17, PowerDVD and ZoomPlayer as playback software
    Hobsyssel mastiffs: http://www.hobsyssel.no

  4. #4
    Join Date
    May 2004
    Posts
    2,589

    Default

    Is there any way to attach a file? (ie.- security camera still-shot)

  5. #5
    Join Date
    Nov 2003
    Location
    Hove, E Sussex, UK
    Posts
    4,005

    Default

    Quote Originally Posted by Mastiff
    Very nice! Did Tony answer you?
    No. :evil:
    Thx, Dan

    Onwards and Upwards!
    http://www.danward.co.uk

  6. #6
    Join Date
    Nov 2003
    Location
    Hove, E Sussex, UK
    Posts
    4,005

    Default

    Quote Originally Posted by quixote
    Is there any way to attach a file? (ie.- security camera still-shot)
    Yep! If it is just an image you want to attach I beleive it is possible may ned some modification thou.

    Is the image a jpeg?
    Thx, Dan

    Onwards and Upwards!
    http://www.danward.co.uk

  7. #7
    Join Date
    May 2004
    Posts
    2,589

    Default

    Yes. I can capture it as a JPEG.

  8. #8
    Join Date
    Nov 2003
    Location
    Hove, E Sussex, UK
    Posts
    4,005

    Default

    Ok,

    I will have a closer look tonight, I beleive there is an example in the manual for sending an image.

    I am interested in this to, so I will have a play over the next few days.

    What size are the images are they 640 x 480, and how do you capture them?
    Thx, Dan

    Onwards and Upwards!
    http://www.danward.co.uk

  9. #9
    Join Date
    Nov 2003
    Location
    Hove, E Sussex, UK
    Posts
    4,005

    Default

    Hey Derek.

    I have managed to send an image using the example, I will now try and adapt the code above for it.

    :wink:
    Thx, Dan

    Onwards and Upwards!
    http://www.danward.co.uk

  10. #10
    Join Date
    May 2004
    Posts
    2,589

    Default

    Beautiful! I use an ATI All-In-Wonder, and the software suite that comes with it. I'll let you know the specifics later on when I am home from work. Thanks!

Page 1 of 25 12311 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •