Communicating With Microsoft Outlook from Revolution |
|
OK, I'll do them in reverse order (Calendar, then Mail) because the mail stuff is a bit tricker...
Manipulating Outlook's Calendar
Here's the basic VBScript, with placeholders surrounded in double angle
brackets << >> :
Of course, there are other properties that can be set for an appointment item, but you get the picture.Const olCalendarFolder = 9 Set oOutlook = WScript.CreateObject("Outlook.Application") Set mNameSpace = oOutlook.GetNameSpace("MAPI") Set oCalFolder = mNameSpace.GetDefaultFolder(olCalendarFolder) Set oApptItem = oCalFolder.Items.Add With oApptItem .Start = "<<START_DATE_TIME>>" .End ="<<END_DATE_TIME>>" .Subject = "<<SUBJECT>>" .Body="<<BODY>>" .ReminderMinutesBeforeStart = <<REMIND_MINS>> End With
Now put that into a custom property (I use "uVBScript" below), and then when you need it, retrieve it, replace the placeholders with real info, and then run it like this:
Manipulating Outlook's Mail Systemon mouseUp put "4/12/05 9:00AM" into tStart put "4/12/05 10:00AM" into tEnd put "Doctor's Appointment" into tSubject put "Call 555-5555 beforehand to confirm." into tBody put 30 into tRemindMins SetAppointment tStart,tEnd,tSubject,tBody,tRemindMins end mouseUp on SetAppointment pStart,pEnd,pSubject,pBody,pRemindMins put the uVBScript of this stack into tScript replace "<<START_DATE_TIME>>" with pStart in tScript replace "<<END_DATE_TIME>>" with pEnd in tScript replace "<<SUBJECT>>" with pSubject in tScript replace "<<BODY>>" with pBody in tScript replace "<<REMIND_MINS>>" with pRemindMins in tScript runScript tScript end SetAppointment on runScript pVBS set the hideConsoleWindows to true put "C:\temp.vbs" into tTempPath put pVBS into url ("file:" & tTempPath) get shell("cscript.exe //nologo" && tTempPath) send "delete file" && quote & tTempPath & quote to me in 1 second -- this gives enough time for the script to run before you delete it end runScript
A few notes:Const olInbox = 6 Const olCC = 2 Const olBCC = 3 Set oOutlook = WScript.CreateObject("Outlook.Application") Set mNameSpace = oOutlook.GetNameSpace("MAPI") Set oMailFolder = mNameSpace.GetDefaultFolder(olInbox ) Set oMailItem = oMailFolder.Items.Add With oMailItem .Recipients.Add("kray@sonsothunder.com") .Recipients.Add("jrosenberg@gilsonco.com").Type = olCC .Recipients.Add("hiddenguy@uknowwho.com").Type = olBCC .Subject = "Here's my attached file" .Body = "This is line 1" & vbCrLf & "This is line 2" .Attachments.Add("C:\myfile.txt") .Display End With
.Body = <<BODY>>
(note no quotes around the placeholder, unlike what I did for the
Appointment Item), and then use a function like:
to format it properly.function MakeBody pMultiLineVal replace CR with (quote & " & vbCrLf & " & quote) in pMultiLineVal return quote & pMultiLineVal & quote end MakeBody
Posted 4/12/2005 by Ken Ray to the Use-Revolution List