Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Appointment Script Suddenly Stops Working

Status
Not open for further replies.

jackiesboy1986

Technical User
Dec 15, 2008
5
US
I am trying to help my work come up with a VBScript that will scan new emails with certain words in a subject. It gets the date and time of the appointment and automatically adds it to a public folder calendar. This is on an exchange server using outlook 2007. I am a newbie to VBScript but have found and modified several scripts to create the one below. The problem is that the script works fine for awhile (while I am testing it at the office) but then when I leave it stops working and I can't get it working again when I come back...Any ideas would be great...

Thanks in adavance

P.S. I am applying the script through a rule...if words in subject then run script:




Attribute VB_Name = "Module11"
Function GetFolder(FolderPath)
' folder path needs to be something like
' "Public Folders\All Public Folders\Company\Sales"
Dim aFolders
Dim fldr
Dim i
Dim objNS

On Error Resume Next
strFolderPath = Replace(FolderPath, "/", "\")
aFolders = Split(FolderPath, "\")

'get the Outlook objects
' use intrinsic Application object in form script
Set objNS = Application.GetNamespace("MAPI")

'set the root folder
Set fldr = objNS.Folders(aFolders(0))

'loop through the array to get the subfolder
'loop is skipped when there is only one element in the array
For i = 1 To UBound(aFolders)
Set fldr = fldr.Folders(aFolders(i))
'check for errors
If Err <> 0 Then Exit Function
Next
Set GetFolder = fldr

' dereference objects
Set objNS = Nothing
End Function
Sub NewMeetingRequest(meetingRequest As Outlook.MailItem)

Set objfolder = GetFolder("Public Folders\All Public Folders\Regional Calendars\The Calendar I Want Here")

' Create meetingRequest

Dim X As Integer

Dim Y As Integer

Dim startDay, startTime, endTime, bodystring As String

bodystring = meetingRequest.Body

' get meeting start day and time (line 7) preceded by "Appearance Date:"

X = InStr(bodystring, "Appearance Date:")

X = X + 17

startDay = Mid(bodystring, X, 10)
If (InStr(startDay, "T")) Then
startDay = Mid(bodystring, X, 9)
Else
startDay = startDay
End If


X = InStr(bodystring, "Appearance Time:")
X = X + 17
startTime = Trim(Mid(bodystring, X, 11))
calcEndTime = startTime



X = InStr(bodystring, "Person:")

X = X + 11

person = Trim(Mid(bodystring, X, 4))

Z = InStr(bodystring, "Other Person")

Z = Z + 15

otherperson = Trim(Mid(bodystring, Z, 75))
K = InStr(otherperson, vbCrLf)
otherperson = Mid(otherperson, 1, K)


Set gotoRequest = objfolder.Items.Add(olAppointmentItem)

gotoRequest.Body = meetingRequest.Body

gotoRequest.Subject = person & " - " & otherperson

gotoRequest.Start = startDay & " " & startTime

gotoRequest.End = startDay & " " & startTime

gotoRequest.ReminderSet = False

gotoRequest.Save

End Sub


 
Are you using a server or client based rule?

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
I am using a client-based rule.

FYI: I have the same script set up on a different computer (just writing to a private calendar) and it has always worked fine.

The thing I find weird is I am not getting any errors or anything..so I can't even debug it :(

Thanks for any help..
 
Comment out the On Error Resume Next instruction.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I tried that.. I still do not get an error

I am importing the VBScript from a thumb drive onto the computer. Once it is imported, I do not need to leave the thumb drive in do I?

I just realized that might be why it stopped working after I left....but you can still see the script in the editor...

Would an anti-virus detect something and make it stop after awhile?

It has me confused because it works for a while...
 
Is there something that you do before you leave, such as logging off, that might cause this to work only when you are there?
Just guessing, since you say you are trying to access a public calendar, as opposed to private one on the other machine, there could be some sort of privileges required.
 
AVG and BitDefender have caused me trouble with VBScript recently. They detect some scripts as viruses because they write to the registry. Setting exclusions to not scan VBS files can resolve that if your AV is blocking you.

I asked about the server/client side because if you are logging out at night then your user session won't be around to run the script. You need to have Outlook open while being logged in as you to ensure the script will run.

Verify that your system is not set to shut down for power saving. Verify that the NIC is not set in power management to allow the system to power it down.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Thanks for the ideas...
I will try turning off the antivirus for a litte bit and see if it will work then.

Let me explain the part where it stops working more..

I get a call from the office lady and she says it is not working anymore. Even when I go back, I tried deleting the module and making another one. Deleting the rule and making another one...I can not get it to work ever again on that computer...This is with us logged in on Outlook and receiving emails.

Any other ideas besides disabling antivirus?
 
Anything listed in the event logs to point to what is happening?

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Is there a way I can view the events log from the client side computer? I doubt they will actually let me get into IT to check the server events log.

(I work in a very beurocratic department)

:)
 
As it is a client side rule I would expect the errors to be in the local machine event logs. Start/Run Eventvwr.msc

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top