Jump to content

[SOLVED] Outlook and iniread stringreplace problem


 Share

Recommended Posts

I know exactly why this doesn't work but have no clue how to fix it.

My inifile is setup like this:

Sm Project Rm=Public Folders/All Public folders/Bookings/Meeting Rooms/Sm Project Rm

I get the data and reformat it to look like this

$objcal = $session.Folders("Public Folders").Folders("All Public folders").Folders("Bookings").Folders("Meeting Rooms").Folders("Sm Project Rm")

however the script doesn't realize that it is not completely a string but actually a command to navigate to a certain folder in outlook.

I could hardcode it correctly in my script. But I don't want to do this. I want the user to be able to change folder paths in the ini-file. Someone has to now how to do this. How do I read stuff from the .inifile and make the script know it's a command?

Thanks in advance.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>

    Local $listview, $button, $item1, $item2, $item3, $input1, $msg
    
    GUICreate("listview items", 420, 250, 100, 200, -1)
    GUISetBkColor(0x00E0FFFF)

    $listview = GUICtrlCreateListView("col1|col2|col3", 0, 0,420,250,bitor($LVS_NOCOLUMNHEADER,$LVS_SORTDESCENDING))

$objOL = ObjCreate("Outlook.Application")

$session = $objOL.GetNameSpace("MAPI")
$names=IniReadSectionNames(@scriptdir&"\ocal.ini")

for $i=1 to $names[0]
    $sectionnames=IniReadSection(@scriptdir&"\ocal.ini",$names[$i])
    for $j = 1 to $sectionnames[0][0]
        $calfullpath='.Folders("'&StringReplace($sectionnames[$j][1],'/','").Folders("')&')'
        Global $objcal = $session&$calfullpath
        calendar2()
    next
Next
$objcal = $session.GetDefaultFolder(9)

func calendar2()
    For $m In $objcal.items
if @YEAR&@MON&@MDAY >= StringLeft($m.start,8) and StringLeft($m.end,8) >= @YEAR&@MON&@MDAY then
    ;ToolTip(StringLeft($m.end,8)&" "& @YEAR&@MON&@MDAY)
    ;sleep(2000)
    
      $item1 = GUICtrlCreateListViewItem($m.subject&"|"&$m.end&"|"&$m.location, $listview)
  
  EndIf
    Next    
    GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 0, $LVSCW_AUTOSIZE)
        $session.logoff
    GUISetState()
        sleep(10000)
EndFunc
Edited by picea892
Link to comment
Share on other sites

Missing a closing double quote in the literal string:

; $calfullpath = '.Folders("' & StringReplace($sectionnames[$j][1], '/', '").Folders("') & ')'
$calfullpath = '.Folders("' & StringReplace($sectionnames[$j][1], '/', '").Folders("') & '")'

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Yes, saw that. I'll post the working version for others who have the same needs.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>

    Local $listview, $button, $item1, $item2, $item3, $input1, $msg
    
    GUICreate("listview items", 420, 250, 100, 200, -1)
    GUISetBkColor(0x00E0FFFF)  

    $listview = GUICtrlCreateListView("col1|col2|col3", 0, 0,420,250,bitor($LVS_NOCOLUMNHEADER,$LVS_SORTDESCENDING))

$objOL = ObjCreate("Outlook.Application")

$session = $objOL.GetNameSpace("MAPI")
$names=IniReadSectionNames(@scriptdir&"\ocal.ini")

for $i=1 to $names[0]
    $sectionnames=IniReadSection(@scriptdir&"\ocal.ini",$names[$i])
    for $j = 1 to $sectionnames[0][0]
        $calfullpath='$session.Folders("'&StringReplace($sectionnames[$j][1],'/','").Folders("')&'")'
        Global $objcal = Execute($calfullpath)
        $busyornot=calendar2()
            
      $item1 = GUICtrlCreateListViewItem($sectionnames[$j][0]&"|"&$busyornot, $listview)
    GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 0, $LVSCW_AUTOSIZE)

    next
Next
GUISetState()
While 1
sleep(1000)
WEnd
;$objcal = $session.GetDefaultFolder(9)

func calendar2()
    For $m In $objcal.items
if @YEAR&@MON&@MDAY >= StringLeft($m.start,8) and StringLeft($m.end,8) >= @YEAR&@MON&@MDAY then
    return "busy"
  EndIf
    Next    
    GUICtrlSendMsg($listview, $LVM_SETCOLUMNWIDTH, 0, $LVSCW_AUTOSIZE)
        $session.logoff
    Return "available"
EndFunc
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...