Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted

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.

Posted

Problem solved by scripting...

 

Const SOURCE_FOLDER As String = "C:\temp\"
Const RECIP_A As String = "[email protected]"
Const RECIP_B As String = "[email protected]"
Const RECIP_C As String = "[email protected]"
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 :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...