Communicating with Outlook

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
wee wullie
Posts: 78
Joined: Fri Oct 03, 2008 10:13 am

Communicating with Outlook

Post by wee wullie » Sun Sep 01, 2013 10:32 pm

Has anyone used the outlook calender code on Ken Rays Sons of Thunder website http://www.sonsothunder.com/devres/live ... iac002.htm, it seems to be the only site with info on this subject,
i have tried using it in a stack but it doesn't work, i tried saving the uVBScript code in the custom properties of the stack itself and then in the custom props of the button, i'm probably missing something very obvious here, if anyone can help - please.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Communicating with Outlook

Post by Simon » Mon Sep 02, 2013 10:55 pm

Hi wullie,
That post needs some updating:
This should go into the stacks custom property uVBScript

Code: Select all

Const olAppointmentItem = 1

Set objOutlook = CreateObject("Outlook.Application")
Set objAppointment = objOutlook.CreateItem(olAppointmentItem)

objAppointment.Start = #<<START_DATE_TIME>>#
objAppointment.Duration = <<END_DATE_TIME>>
objAppointment.Subject = "<<SUBJECT>>"
objAppointment.Body = "<<BODY>>"
objAppointment.ReminderMinutesBeforeStart = <<REMIND_MINS>>
objAppointment.ReminderSet = True
 
objAppointment.Save
And in the button:

Code: Select all

on mouseUp
  put "9/3/13 9:00AM" into tStart
  put "60" 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 specialFolderPath("desktop") & "\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
Aside from the custom script I did do a few changes to the button script
tEnd is now in minutes from tStart
and I am using the desktop to put the vbscript.

Simon
Edit: This is working with Outlook 2010 Windows (naturally)
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

wee wullie
Posts: 78
Joined: Fri Oct 03, 2008 10:13 am

Re: Communicating with Outlook

Post by wee wullie » Mon Sep 02, 2013 11:59 pm

Outstanding Simon, it works superbly , thank you so much for your help :D

kindest regards
Wullie

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Communicating with Outlook

Post by Simon » Tue Sep 03, 2013 12:19 am

Glad it works for you!
Using C:\temp.vbs wasn't working for me, you probably want to change desktop to documents.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply