|
Sub
Main()
Dim
objMilestones
As
Object
Dim
CurrentDate1
As
Variant
Dim
StartDate1
As
Variant
Dim
EndDate1
As
Variant
Dim
PercentComplete1
As
Integer
Dim
objOutlook
As
Outlook.Application
Dim
objItem
As
Outlook.MailItem
Dim
syms
As
Integer
'Enter filename to use here:
Set
objMilestones = GetObject("[MilestonesFilename]")
With
objMilestones
.Activate
'Open Milestones
CurrentDate1 = .GetCurrentDate
StartDate1 = .GetSymbolProperty(1,
1, "Date")
syms = .GetNumberOfSymbolsInLine(1)
EndDate1 = .GetSymbolProperty(1, syms, "Date")
PercentComplete1 = .GetPercentComplete(1)
.Save
.Close
'You can get a lot of data from Milestones
'schedules using our Automation Methods.
'A list with a description of each method is
available on the Help menu
End With
'Create Outlook object
Set
objOutlook = CreateObject("Outlook.Application")
'Create a new e-mail message
Set
objItem = objOutlook.CreateItem(olMailItem)
With
objItem
'Set the recipient for the new email
.To = "username1@domain.com"
'Set multiple recipients as a cc
.CC = "username2@domain.com; username3@domain.com"
'Set the subject
.Subject = "Milestones Data"
'The following will create simple text used as the body
'for the email; "vbCrLf" creates a line break.
.Body = "Taskline as of " & CurrentDate1 & ":" & vbCrLf & " Start
Date: " _
& StartDate1 & vbCrLf & " End Date: " & EndDate1 & vbCrLf & _
" Percent Complete: " & PercentComplete1 & "%" & vbCrLf & vbCrLf
'Send the Email
.Send
End With
End Sub
You can also get
information from multiple schedules by repeating the code from the first
Set objMilestones to the End With. Just change the file
name and any different information you want to get from each file. You
can also create the body of the e-mail using HTML in order to format
your status updates in many different ways. To do this you would need to
substitute the .Body method with .HTMLBody;
.HTMLBody =
"<HTML><BODY><B>You can also format using HTML</B></Body></HTML>"
To set up your
task scheduler, go to Start | Settings | Control Panel | Scheduled
Tasks | Add Task. Click Next, browse for the .exe you created with
VB6, and set the timing settings for how often you want this sent out.
With this completed, updates will be sent automatically with no more
effort on your part. |