Run code once form is sent

L

LDMueller

I created a form in Outlook 2003 with a command button. The code behind the
button is as follows:

Sub cmdScheduleNotification_Click()

dte = FormatDateTime(Item.UserProperties("Laptop Needed Date"), vbShortDate)
tme = FormatDateTime(Item.UserProperties("Laptop Needed Time"), vbShortTime)

Set myItem = Application.CreateItem(1)
myItem.MeetingStatus = 1
myItem.Subject = "Issue Equipment"
myItem.Location = "Equipment is for " & Item.UserProperties("For")
myItem.Start = CDate(dte & " " & tme)
myItem.Duration = 0 'was 90
myItem.ReminderMinutesBeforeStart = 30 '1 day reminder = 1440, 1 week =
10080
myItem.BusyStatus = Free

Set myRequiredAttendee = myItem.Recipients.Add ("LDM")
myRequiredAttendee.Type = 1
Set myOptionalAttendee = myItem.Recipients.Add ("JDE")
myOptionalAttendee.Type = 2
myItem.Send

msgbox "Notification has been Scheduled"

End Sub

This code works fine, however, instead of running the code by pressing the
command button, I'd rather the code run once the user presses "SEND" (after
of course they complete the form).

Can someone help me with this.

Thanks in advance!

LDMueller
 
K

Ken Slovak - [MVP - Outlook]

In the form code window select Script, Event Handler. Add the Send event to
the code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top