+ Post New Thread
Results 1 to 2 of 2
Office Software Thread, Automated Email with attachments in Technical; I want to set up an automated email, that will send me an email every night at around 1am, with ...
  1. #1

    nephilim's Avatar
    Join Date
    Nov 2008
    Location
    Dunstable
    Posts
    11,807
    Thank Post
    1,624
    Thanked 1,880 Times in 1,397 Posts
    Blog Entries
    2
    Rep Power
    423

    Automated Email with attachments

    I want to set up an automated email, that will send me an email every night at around 1am, with a log file attachment which it pulls from a specified data source on said machine. Any ideas how I can set this up on outlook 2007?

    I've looked into scripting but not too keen on it. Any and all help appreciated.

  2. #2

    nephilim's Avatar
    Join Date
    Nov 2008
    Location
    Dunstable
    Posts
    11,807
    Thank Post
    1,624
    Thanked 1,880 Times in 1,397 Posts
    Blog Entries
    2
    Rep Power
    423
    Problem solved by scripting...

    Code:
    Const SOURCE_FOLDER As String = "C:\temp\"
    Const RECIP_A As String = "a@a.com"
    Const RECIP_B As String = "b@b.com"
    Const RECIP_C As String = "c@c.com"
    Const SUBJECT As String = "ABC001 Logs"
    Const EMAIL_BODY As String = "Please find attached file. Thanks and Regards, ABC"
    
    Sub Sendlogs()
    
      On Error GoTo ErrorHandler
    
      Dim fileName As String
    
      fileName = Dir(SOURCE_FOLDER)
    
    Do While Len(fileName) > 0
    Call CreateEmail(SOURCE_FOLDER & fileName)
    fileName = Dir
    Loop
    
    ProgramExit:
      Exit Sub
    ErrorHandler:
      MsgBox Err.Number & " - " & Err.Description
      Resume ProgramExit
    End Sub
    
    Function CreateEmail(fileName As String)
    
    Dim olApp As Outlook.Application
    Dim msg As Outlook.MailItem
    
      ' create email
      Set olApp = Outlook.Application
      Set msg = olApp.CreateItem(olMailItem)
    
      ' set properties
      With msg
        .SUBJECT = SUBJECT
        .Body = EMAIL_BODY
        .Recipients.Add (RECIP_A)
        .Recipients.Add (RECIP_B)
        .Recipients.Add (RECIP_C)
        .Attachments.Add fileName
        .Send
      End With
    
    End Function
    set a script for the outlook to start running the vbs, then set a script for the outlook to close after an hour.

    Job done

SHARE:
+ Post New Thread

Similar Threads

  1. Auto Reply to emails with an Attachment
    By Heggy in forum How do you do....it?
    Replies: 7
    Last Post: 25th March 2011, 02:01 PM
  2. Replies: 5
    Last Post: 14th September 2009, 01:07 PM
  3. Replies: 6
    Last Post: 15th May 2007, 01:56 PM
  4. Internal/External Email with ISA and Exchange 2000
    By Ueline in forum Wireless Networks
    Replies: 5
    Last Post: 7th December 2005, 11:00 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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