anton Posted February 12, 2009 Posted February 12, 2009 Hi All, I am trying to make a script that creates a calendar appointment in the public folder on a certian calendar. The calendar is called test and every time I try to run the script it errors when it triest to go to the public folder path? What am I doing wrong? I am new to all this and any help is appreciated. Anton #include <Date.au3> Const $olAppointmentItem = 1 Dim $objOL, $session, $calendar $path = ("\\Public Folders\All Public Folders\test") $objOL = ObjCreate("Outlook.Application") $session = $objOL.GetNameSpace("MAPI") $calendar = $session.GetDefaultFolder($path) $calendar.CreateItem ($olAppointmentItem) $calendar.Location = "" $calendar.Subject = "subject here" $calendar.Body = "text" $calendar.Start = "2/12/2009" $calendar.AllDayEvent = 1 $calendar.Save
Authenticity Posted February 12, 2009 Posted February 12, 2009 MAPIFolder object doesn't contain any .CreateItem, .Loation, .Subject, .Body, etc.. properties or methods. Don't you have Object Browser?
anton Posted February 19, 2009 Author Posted February 19, 2009 Thanks for the reply Authenticity it helped me get on the right track. I have taken a sample script and modified it to suit my needs, one problem, I keep getting an error? This is what happens.... CODEDim $objApp Dim $objNS Dim $colFolders Dim $objFolder Dim $olAppointmentItem $oFolder = _GetFolder ("Public Folders\All Public Folders\test") Func _GetFolder($strFolderPath) Dim $i $arrFolders = StringSplit($strFolderPath, "\") $objApp = ObjCreate("Outlook.Application") $objNS = $objApp.GetNamespace("MAPI") $objFolder = $objNS.CreateItem($olAppointmentItem) $objFolder.Location = "" $objFolder.Subject = "subject here" $objFolder.Body = "text" $objFolder.Start = "2/12/2009" $objFolder.AllDayEvent = 1 $objFolder.Save ConsoleWrite(ObjName($objFolder) & @CR) If IsObj($objFolder) Then For $i = 2 To $arrFolders[0] $colFolders = $objFolder.Folders $objFolder = $colFolders.Item($arrFolders[$i]) If Not IsObj($objFolder) Then ExitLoop EndIf Next EndIf Return $objFolder EndFunc This is the error I cannot get around? >Running:(3.2.2.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\anton.j\Desktop\auto it\temp1.au3" C:\Documents and Settings\anton.j\Desktop\auto it\temp1.au3 (22) : ==> The requested action with this object has failed.: $objFolder = $objNS.CreateItem($olAppointmentItem) $objFolder = $objNS.CreateItem($olAppointmentItem)^ ERROR What am i missing??? Any help would be great! Thanks, Anton
Authenticity Posted February 19, 2009 Posted February 19, 2009 Dim $objApp Dim $objNS Dim $colFolders Dim $objFolder Dim $olAppointmentItem = 1 $oFolder = _GetFolder ("Public Folders\All Public Folders\test") ConsoleWrite($oFolder & @CRLF) Func _GetFolder($strFolderPath) Dim $i $arrFolders = StringSplit($strFolderPath, '\', 1) $objApp = ObjCreate("Outlook.Application") $objNS = $objApp.GetNamespace("MAPI") $objFolder = $objApp.CreateItem($olAppointmentItem) $objFolder.Location = "" $objFolder.Subject = "subject here" $objFolder.Body = "text" $objFolder.Start = "2/12/2009" $objFolder.AllDayEvent = 1 $objFolder.Save ConsoleWrite(ObjName($objFolder) & @CR) If IsObj($objFolder) Then For $i = 1 To $arrFolders[0] $colFolders = $objNS.Folders ;$objFolder = $colFolders.Item($arrFolders[$i]) ??? If Not IsObj($objFolder) Then ExitLoop Next EndIf Return $objFolder EndFunc Please get your self an object browser because it's impossible to guess which property or method or object belongs to. I've commented the ";$objFolder = $colFolders.Item($arrFolders[$i])" parts because I don't have Outlook except for it's COM object to test what does it supposed to do... You're sending a string to a function that expects an integer value.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now