Excellent call on the validation... However, I am getting an error with the cDate:
Type mismatch: 'CDate'
Code: 800A000D
VB Runtime error
Here is the new code, I also added functions out thew wazoo to control moving around in the script. Im a noob :]
[script]
' developed by Mike KOvacic
' Remedy Reminder script
' Soursecode is copyright Mike Kovacic and IKON
' Instructions for use:
'
' ¤ Doubleclick on the script
' ¤ Insert Ticket number not including zeros || Hit OK
' ¤ Insert short description, this is what will show up in outlook as the item || Hit OK
' ¤ Insert the time in minutes that outlook should remind you. By default, the reminder will notify you 1 minute before you set the time
' ¤ Keep in mind that there are 60 minutes in an hour and 1440 minutes in a day. || Hit OK
' ¤ Afer a short pause, the reminder will be created. It can be edited or removed by going into your outlook calendar and opening the item.
'
' That all there is to it. One thing to keep in mind,this scrip[t will create a folder located at C:\remtemp
' You may wish to clean this folder, but any future remedy reminders createdby this program you have set may not work.
' You can also use this folder to see what tickets you have set in the past.
'
'
' Have Fun, source code is shown below, don't change it unless you know what you are doing, and do not remove this notice.
Call Main
function main
Dim objFSO, objFolder, objShell, strDirectory,WshShell,iklogname,subject,whenday,whentime,whenwhen,remedyticket,OlApp,nsNameSpace,olFolderCalendar,olEvent,olByValue,a,b
a = a
strDirectory = "c:\remtemp"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
else
Set objFolder = objFSO.CreateFolder(strDirectory)
end if
Set WshShell = WScript.CreateObject("WScript.Shell")
call askremedy
end function
function askremedy
iklogname = InputBox("Input your Remedy Ticket number." & vbCrLf &"[not including the zeros.]", "Remedy Ticket Number v. 1.3")
If iklogname = "" Then
call badremnumber
Else
subject = InputBox("Give a quick description of ticket."& vbCrLf &" [example: user is back from vacation, reinstall vpn]", "Quick description")
END IF
call askday
end function
function askday
whenday = Inputbox("What DAY would you like to set this reminder for? "& vbCrLf &"[Leave field blank for today]" & vbCrLf & vbCrLf & "(Format: "& date() & ")" , "Remind me in...")
If whenday = "" Then
whenday = Date()
end if
If Not IsDate(whenday) Then
call baddate
end if
call asktime
end function
function asktime
whentime = Inputbox("What TIME would you like to set this reminder for? "& vbCrLf &"[Leave field blank for one hour]" & vbCrLf & vbCrLf & "(Format: "& time() & ")" , "Remind me in...")
whenwhen = (whenday & " " & whentime)
'whenwhen = ("#" & whenday & " " & whentime & "#")
If whentime = "" Then
a = b
whentime = DateAdd("h",+1,Time())
whenwhen = (whentime)
'whenwhen = ("#"& whentime & "#")
end if
If Not IsDate(whentime) Then
call badtime
end if
call makefile
end function
function makefile
DIM fso, GuyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set remedyticket = fso.CreateTextFile( "C:\remtemp\RemedyTicket " & iklogname & ".ARTask", True)
remedyticket.WriteLine("[Shortcut]")
remedyticket.WriteLine ("Name = HPD:HelpDesk")
remedyticket.WriteLine ("Type = 0")
remedyticket.WriteLine ("Server = MyRemedyServer")
remedyticket.WriteLine ("Join = 0")
remedyticket.WriteLine ("Ticket = 00000000" & iklogname)
remedyticket.Close
call addreminder
end function
function addreminder
Set OlApp = CreateObject("Outlook.Application")
Set nsNameSpace = OlApp.GetNamespace("MAPI")
Set olFolderCalendar = nsNameSpace.GetDefaultFolder(9) 'olFolderCalendar
Set olEvent = OlApp.CreateItem(1)
'olAppointmentItem
'olEvent.Start = DateAdd("n", when, Now())
whenwhen = CDate(whenday & " " & whentime)
msgbox ("CDate = " & whenwhen)
'whenwhen = (#8/6/2009 11:05 PM#)
msgbox whenwhen
olEvent.Start = whenwhen
olEvent.Subject = subject
olEvent.ReminderSet = True
olEvent.ReminderMinutesBeforeStart = 5
olEvent.Attachments.Add "C:\remtemp\RemedyTicket " & iklogname & ".ARTask", _
olByValue, 1, "Test"
olEvent.Save
call finalword
end function
function finalword
MsgBox ("Ticket: " & iklogname & vbCrLf & "Subject: " & subject & vbCrLf & "Date: " & whenday & vbCrLf & "Time : " & whentime & vbCrLf & vbCrLf & "The event has been created in your Outlook calendar. Should you need to cancel or change your reminder, it must be done through outlook.")
end function
function baddate
MsgBox ("Please try again, use the following format: m/dd/yy")
Call askday
end function
function badtime
MsgBox ("Please try again, use the following format: h:mm (AM/PM)")
Call asktime
end function
function badremnumber
MsgBox ("I can not create a reminder if you don't give me a ticket number.")
call askremedy
end function
[/script]