Lesson Objectives
Upon completion of this lesson, the participant will be able to:
Some Topics to be introduced in this lesson include:
Programming Workgroup Features
This section includes a discussion of the macro commands related to the mail features in MSProject. See Online Help for full documentation. Here's the macro commands as they are used in the default standard menu (right click the menu bar and choose customize, then edit the Standard menu bar):
Menu item |
Macro command |
File | |
Send |
MailSend |
[Add/Edit Routing Slip] |
MailRoutingSlip |
Tools, Multiple Project | |
Open from Database |
Macro "OpenFromDatabase" |
Save to Database |
Macro "SaveToDatabase" |
Tools, Workgroup | |
Send Task Request |
MailSendProjectMail |
Send Task Update |
MailSendProjectMail MessageType:="TaskUpdates" |
Request Task Update |
MailSendProjectMail MessageType:="UpdateRequest" |
Set Reminder |
SchedulePlusReminderSet |
Send Schedule Note |
MailSendScheduleNote |
The available mail related macro commands are listed and discussed below:
Note the difference between establishing a session and running the Mail application itself. None of the MSProject mail commands start the Mail application directly, although you'll get a system message asking if you want to log on to mail.
Email Address
Some of the mail commands can automatically send mail to resources (commands without a "To" argument). If the Email Address field for a resource is nonblank, then it must contain a valid email name. If the Email Address field is blank, then the resource name field is used instead.
MailSend to, cc, subject, body, enclosures, includeDocument, returnReceipt
What it sends: Normal piece of mail with options for attachments (enclosures), and an option to attach a copy of the active project.
Who it goes to: Recipients specified by the to argument.
Some of the arguments are discussed below. See Online Help for complete documentation.
enclosures
Can be a string containing a list of filenames to attach to the mail.
includeDocument
Set True to attach a copy of the active project.
body
Can be multiline text (e.g. s="line1" & chr(10) & "line2")
to
Online Help says the "to" argument can be a list of names separated by semicolons. However, MailSend actually treats them as a single name. For example,
MailSend To:="Jim; Mary"
causes an error message saying it can't find "Jim; Mary".
Leave out the To: argument to get a dialog box.
MailRoutingSlip to, subject, body, allAtOnce, returnWhenDone, trackStatus,
clear, sendNow
What it sends: Normal piece of mail with an attached copy of the active project.
Who it goes to: Recipients specified by the to argument.
Some of the arguments are discussed below. See Online Help for complete documentation.
to
Same as in the MailSend method.
clear
After a routing slip is sent, the File menu changes "Add Routing Slip" to "Edit Routing Slip"; if you send the slip again, you get the message:
You have routed this project before. Do you want to route it again?
To reset it, use:
MailRoutingSlip Clear:=True
sendNow
Prevents the mail from being sent if set to False.
MailSendProjectMail messageType, subject, body, fields, updateAsOf, showDialog, installationMessage
What it sends: Depends on the messageType argument. See below.
Who it goes to: Sends mail to resources assigned to the tasks - each resource only receives mail about the tasks it is assigned to.
The arguments subject and body replace default expressions.
The Project must be saved - otherwise it tells you it must be saved and asks if you want to save it.
A task table must be active. Depending on the value of the messageType argument, it will look at all tasks, selected tasks, or it will prompt you. If messageType is "Custom" , then it looks only at selected tasks, and you get an error if no tasks are selected. The other choices for messageType behave as follows: It looks at selected tasks if more than one task is selected. If only one task is selected, then it prompts you to choose all tasks or selected tasks. If no task is selected, then it looks at all tasks.
Some of the arguments are discussed below. See Online Help for complete documentation.
messageType
This is the most important argument. It can be one of the following strings:
"Custom"
"TaskRequest" (default)
"TaskUpdates"
"UpdateRequest"
messageType:="Custom" - Sends specified field information to resources assigned to selected tasks. You must specify the fields argument otherwise you get a fields dialog to select from. When a resource opens the mail, the fields cannot be edited. The resource can send a response, but the original sender can't use the response to update fields in the project.
messageType:="TaskRequest" - Asks resources to accept task assignments. When a resource opens the mail, the fields automatically included are:
Accept?
Task Name
Work
Start
Finish
Comments
If the fields argument is used, then additional read only fields show up to the right of the automatic ones. Only "Accept?" and "Comments" can be edited when a resource opens the mail. When the resource replies and confirms the task, it automatically tries to make a task in the resource's Schedule+.
messageType:="TaskUpdates" - Tells resources of changes in assigned task dates. It only includes tasks with Yes in the "Update Needed" task field, which only happens if at least one resource confirmed a request, and the dates have since changed. The task "Confirmed" field is Yes if no resources are assigned to a task. If a task has resources, then "Confirmed" is No until all resources assigned to the task have confirmed task requests.
BUG: If R confirms T, and then R is unassigned and reassigned to T, then TaskUpdates asks if you want to send mail to R to tell it that it's no longer assigned to T.
When a resource opens the mail, the fields automatically included are:
Task Name
Work
Start
Finish
Comments
If the fields argument is used, then additional read only fields show up to the right of the automatic ones. None of the fields can be edited. If a resource opens the mail and chooses the "Update Schedule+" button, then a new task is added to the resource's Schedule+ with the updated dates - it doesn't remove the old task from Schedule+.
messageType:="UpdateRequest" Requests status from resources on the selected tasks.
The updateAsOf argument is only used if the messageType is "UpdateRequest". It causes the following phrase to show up in the mail:
Enter status as of : ...
It will send update requests to a resource even if the resource has never confirmed a TaskRequest.
When a resource opens the mail, the fields automatically included are:
Task Name
Start
Work
Completed
Remaining Work
Comments
If the fields argument is used, then additional read only fields show up to the right of the automatic ones. The task Name field and any extra fields cannot be edited or updated. If a resource opens the mail and double clicks any field or selects the Reply button, the Reply button changes to a Send button, and a question mark character is placed by the following field names: Start, Work Completed, and Remaining Work. At that point, the resource can edit the fields with the question marks.
NOTE: If a resource opens the mail and changes the start date, then the task in Schedule+ does not get updated.
fields
Specifies the (only) task fields used if messageType:="Custom", or additional fields used with other message types. Titles can be put in square brackets after field name, e.g. Fields:="Duration,Name[Event],Start". Some fields like Name use the default title like Task Name unless you specify a title in []. The titles used in the project tables don't matter.
Note: When a resource opens the mail, they cannot edit any of the extra fields specified by the fields argument. The extra fields appear to the right of the automatic fields.
installationMessage
Optional message that replaces the default error message that occurs if the message handler is not properly installed.
MailSendScheduleNote manager, taskContacts, resources, selection, includeDocument, includePicture, body, subject
What it sends: Normal piece of mail with options for attaching a copy and/or picture of the active project.
Who it goes to: All resources or selected resources or resources assigned to selected tasks, depending on the active view and the value of the selection argument. There are also options to include the manager and contacts in the mailing list.
It works in any view. The selection argument can be true if a task or resource table is active.
The arguments subject and body replace default expressions.
MailUpdateProject dataFile
The dataFile argument must be the fullname of the kind of file invisibly attached to a mail reply to a TaskRequest or a mail reply to an UpdateRequest. To get this filename, you need to use MAPI calls in MAPI.dll and/or VBAMAPI.dll, or write a VB application using the MAPI Session and MAPI Messages custom controls (In VB, choose File, Add File, and select MSMAPI.VBX - it's probably in the system directory). Note that you can't use File, Save Attachment in mail to save this special kind of attachment.
If it's the right kind of data file, then MSProject reads it and updates the appropriate project.
SchedulePlusReminderSet start, leadTime
For each selected task and each resource assigned, it creates an appointment with a reminder for the resource in Schedule+. A task table must be active.
Note: SchedulePlusReminderSet creates appointments in Schedule+, whereas MailSendProjectMail (with messagetype:= "TaskRequest" or "TaskUpdates" or "UpdateRequest") creates tasks in Schedule+.
MailLogoff
Do this after other MSProject mail commands, otherwise you can't exit and sign out of the mail application while project is still running - you can exit Mail, but you can't exit and sign out. MailLogoff notifies the mail spooler that it is done using it.
MailLogon name, password, downloadNewMail
Allows you to start a session without the sign on dialog box - if you know the user name and password - and control whether new mail is downloaded. The name argument is the name of the user who will be sending mail.
MailSession
You can check if this property is Null to see if another mail command failed, for example:
On Error Resume Next
MailLogon
If IsNull(MailSession) then ...
MailSystem
You can use this property to find out what type of mail system is available:
0 pjNoMailSystem Unrecognized or none
1 pjMAPI Microsoft Mail
3 pjMAPICompatible MAPI compatible
Standard Rate: $20.00/h
Overtime Rate: $30.00/h
The mail subject line is: Rates
Use the To, Subject, Body, and IncludeDocument arguments of the MailSend method. You need to set the IncludeDocument argument to False to prevent it from attaching a copy of the active project to the mail (IncludeDocument defaults to True).
Test it out on a project that has some valid email names entered in the resource EmailAddress field. Open the mail and see if it worked.