reference a field for Date in objAppointment.Start

O

obespalov

How do I reference a text or date picker field for objAppointment.Start
part of the script?



Const olAppointmentItem = 1

Set objOutlook = CreateObject("Outlook.Application")

Set objAppointment = objOutlook.CreateItem(olAppointmentItem)

objAppointment.Start = #11/3/2005 11:00 AM#

objAppointment.Duration = 60

objAppointment.Subject = "Complete Applicant Review"

objAppointment.Body = "Make sure all feedback is complete and create
feedback summary."

objAppointment.Location = ""

objAppointment.ReminderMinutesBeforeStart = 15

objAppointment.ReminderSet = True







objAppointment.Save
 
F

Franck Dauché

Hi,

Your need to point to the node associated with your Date Picker and convert
the ISO8601 Date by scripting.

In JScript for example, it would be:

var date1 = XDocument.DOM.selectSingleNode( "//my:field1" ).text;
var dt1 = ISO8601ToDate(date1);
// dt1 can then be used as a regular date
function ISO8601ToDate(dateString)
{return new Date(dateString.split('-').reverse().join('/')) }

Hope that it helps.

Regards,

Franck Dauché
 
O

obespalov

Thanks for both responses. I'm not sure in which forum to respond back
so I'll try here first.

Would you know by any chance how to do this in VB script?
 
O

obespalov

(Also posted in the other forum by accident)
Thanks, I got the code to work (below). Would you know the statement to
use to add 1 week to whatever date it's referencing in the field?


Dim objField

Set objField =
XDocument.DOM.selectSingleNode("//my:myFields/my:Date_Interview")

Const olAppointmentItem = 1

Set objOutlook = CreateObject("Outlook.Application")

Set objAppointment = objOutlook.CreateItem(olAppointmentItem)

dim theDate

theDate = objField.text & " 9:00 AM"

objAppointment.Start = theDate

objAppointment.Duration = 60

objAppointment.Subject = "Complete Applicant Review"

objAppointment.Body = "Make sure all feedback is complete and create
feedback summary."

objAppointment.Location = ""

objAppointment.ReminderMinutesBeforeStart = 15

objAppointment.ReminderSet = True

objAppointment.Save

End Sub
 
F

Franck Dauché

Hi,

You had 2 parts to your original question:
How to get your date from a textbox or from a Date Picker.

To do any date manipulation, you need to turn your node content into a date.
Starting from a string (which is what you now decided to do) is easier.
From a date picker, you will need that extra ISO 8601 conversion.

At the end of the day, it is the same date manipulation in VBScript (see the
link in my previous post).

Hope that it helps.

Regards,

Franck Dauché
 
O

obespalov

Finally, here is the solution. I am posting here for others searching
in the future...

Dim objField

Set objField =
XDocument.DOM.selectSingleNode("//my:myFields/my:Date_Interview")

if objField.text <> "" then

Const olAppointmentItem = 1

Set objOutlook = CreateObject("Outlook.Application")

Set objAppointment =
objOutlook.CreateItem(olAppointmentItem)

dim theDate

theDate = objField.text

theDate = DateAdd("D", 7, theDate)

theDate = theDate & " 9:00 AM"

objAppointment.Start = theDate

objAppointment.Duration = 60

objAppointment.Subject = "Complete Applicant Review"

objAppointment.Body = "Make sure all feedback is
complete and create feedback summary."

objAppointment.Location = ""

objAppointment.ReminderMinutesBeforeStart = 15

objAppointment.ReminderSet = True

objAppointment.Save

End if
 

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

Top