visler

Deleting appointment in outlook

12 posts in this topic

Hi all

I been using autoit some years ago and needed a tool for changing various in outlook so i found autoit again and i allready succeed in some of this, but i cant find and delete an appointment.

I have found this example and the creation is ok (after i changed $oOL/$oOutlook typo)

Https://www.autoitscript.com/wiki/OutlookEX_UDF_-_Meeting_Item

But i cant get the delete part to work and i keep on getting "not found" and an empty array (screen shoot of _ArrayDisplay attached)

Please can someone tell me what i am missing, i have been searching and trying various but stil i have no luck in finding any items.

I am using outloook 2013 and office365. I have been able to send mails and create appointment, so i guess my problem is not due to the use off office365.


 

ScreenHunter_1774 Nov. 02 08.06.jpg

Share this post


Link to post
Share on other sites



I fixed the typos in the wiki.

Can you please post the code you use to create and delete the appointment?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I have tried various thing, but using the examples creates a meeting ok, but the deleting example does not work for me

 

"#include <OutlookEx.au3>
; Open the connection to Outlook
Global $oOL = _OL_Open()
; Get the appointment you want to cancel
$aResult = _OL_ItemFind($oOL, "*\Calendar", "", "[Subject]='Meeting'", "", "", "EntryID")
_ArrayDisplay
$oItem = _OL_ItemModify($oOL, $aResult[1][0], Default, "MeetingStatus=5")
; Send the meeting request
_OL_ItemSend($oOL, $oItem)

Edited by visler

Share this post


Link to post
Share on other sites

What is the value of @error and @extended after calling _OL_ItemModify and _OL_ItemSend?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I have updated the code to display error codes and screenshoot attached

"#include <OutlookEx.au3>
; Open the connection to Outlook
Global $oOL = _OL_Open()
; Get the appointment you want to cancel
$aResult = _OL_ItemFind($oOL, "*\Calendar", "", "[Subject]='Meeting'", "", "", "EntryID")
MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Errorcode " & @error & ", @extended: " & @extended)
;
$oItem = _OL_ItemModify($oOL, $aResult[1][0], Default, "MeetingStatus=5")
MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Errorcode " & @error & ", @extended: " & @extended)
; Send the meeting request
_OL_ItemSend($oOL, $oItem)

ScreenHunter_1774 Nov. 02 09.45.jpg

ScreenHunter_1774 Nov. 02 09.47.jpg

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Please give this modified version of your script a try:

#include <OutlookEx.au3>
; Open the connection to Outlook
Global $oOL = _OL_Open()
; Get the appointment you want to cancel
$aResult = _OL_ItemFind($oOL, "*\Calendar", $olAppointment, "[Subject]='Meeting'", "", "", "EntryID,MeetingStatus")
MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Errorcode " & @error & ", @extended: " & @extended)
_ArrayDisplay($aResult)
If $aResult[0][0] > 0 Then ; Items found
    If $aResult[1][1] = 0 Then ; Item is not a meeting, so simply delete it
        _OL_ItemDelete($oOL, $aResult[1][0])
    Else
        $oItem = _OL_ItemModify($oOL, $aResult[1][0], Default, "MeetingStatus=5")
        MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Errorcode " & @error & ", @extended: " & @extended)
        ; Send the meeting request
        _OL_ItemSend($oOL, $oItem) 
    EndIf
EndIf

If the value of MeetingStatus ($aResult[1][1]) is not 1 then you do not need to send a delete request but simply delete the item.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Now the array looks better :)

I am not sure I understand the part about deleting the item instead off sending a delete request.

if MeetingStatus ($aResult[1][1]) <> 1  then

      _OL_ItemDelete($oOL, where do i get this entryid)  
else

    $oItem = _OL_ItemModify($oOL, $aResult[1][0], Default, "MeetingStatus=5")

endif

 

ScreenHunter_1774 Nov. 02 10.44.jpg

ScreenHunter_1775 Nov. 02 10.44.jpg

Share this post


Link to post
Share on other sites

I modified my script in post #6 (note that I removed the quotes around $olAppointment).
It now distinguishes between meetings (multiple participants) and appointments (entry can only be found in your calendar).


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I have added a few displays.

#include <OutlookEx.au3>
; Open the connection to Outlook
Global $oOL = _OL_Open()
; Get the appointment you want to cancel
$aResult = _OL_ItemFind($oOL, "*\Calendar", $olAppointment, "[Subject]='Meeting'", "", "", "EntryID,MeetingStatus")
MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Errorcode " & @error & ", @extended: " & @extended)
_ArrayDisplay($aResult)
If $aResult[0][0] > 0 Then ; Items found
    If $aResult[1][1] = 0 Then ; Item is not a meeting, so simply delete it
        _OL_ItemDelete($oOL, $aResult[1][0])
        MsgBox(48, "OutlookEX UDF: _OL_Itemdelete", "Errorcode " & @error & ", @extended: " & @extended)
    Else
        $oItem = _OL_ItemModify($oOL, $aResult[1][0], Default, "MeetingStatus=5")
        MsgBox(48, "OutlookEX UDF: _OL_Itemmodify", "Errorcode " & @error & ", @extended: " & @extended)
        ; Send the meeting request
        _OL_ItemSend($oOL, $oItem)
        MsgBox(48, "OutlookEX UDF: _OL_Itemsend", "Errorcode " & @error & ", @extended: " & @extended)
    EndIf
EndIf

Now the array returned look much more like i expected and all is returning 0 in errorcodes, but it looks like the appoint is not deleted and a re-run gives the same result in the array, but if i delete one of the meetings by hand the results is decreased by 1 .

 

ScreenHunter_1775 Nov. 02 12.28.jpg

ScreenHunter_1777 Nov. 02 12.32.jpg

ScreenHunter_1777 Nov. 02 12.28.jpg

ScreenHunter_1776 Nov. 02 12.28.jpg

Share this post


Link to post
Share on other sites

Seems you then need to delete the meeting from your calendar manually:

#include <OutlookEx.au3>
; Open the connection to Outlook
Global $oOL = _OL_Open()
; Get the appointment you want to cancel
$aResult = _OL_ItemFind($oOL, "*\Calendar", $olAppointment, "[Subject]='Meeting'", "", "", "EntryID,MeetingStatus")
MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Errorcode " & @error & ", @extended: " & @extended)
_ArrayDisplay($aResult)
If $aResult[0][0] > 0 Then ; Items found
    If $aResult[1][1] = 0 Then ; Item is not a meeting, so simply delete it
        _OL_ItemDelete($oOL, $aResult[1][0])
        MsgBox(48, "OutlookEX UDF: _OL_Itemdelete", "Errorcode " & @error & ", @extended: " & @extended)
    Else
        $oItem = _OL_ItemModify($oOL, $aResult[1][0], Default, "MeetingStatus=5")
        MsgBox(48, "OutlookEX UDF: _OL_Itemmodify", "Errorcode " & @error & ", @extended: " & @extended)
        ; Send the meeting request
        _OL_ItemSend($oOL, $oItem)
        MsgBox(48, "OutlookEX UDF: _OL_Itemsend", "Errorcode " & @error & ", @extended: " & @extended)
        _OL_ItemDelete($oOL, $oItem)
        MsgBox(48, "OutlookEX UDF: _OL_Itemdelete", "Errorcode " & @error & ", @extended: " & @extended)
    EndIf
EndIf

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

:)

Now it works

Thanks a million

Share this post


Link to post
Share on other sites

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
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

  • Similar Content

    • zetaimmersion
      By zetaimmersion
      Hi all. 
      I am trying to do 2 things but i cannot seem to get any traction on how to read/implement this idea.
      Premise: PowerPoint file in C\temp\presentation.pptx that contains on the first slide 2 entries as "<one>" and "<two>" which need to be replaced with "user1" and "user2", then a silent Outlook send mail containing the file with a predefined body and subject.
      I narrowed it down to COM objects as the Office does not like intrusive open AutoIt functions. I installed OLE/COM Object Viewer to understand how to create the commands but i am still stuck. So far i am trying to user water's code but i suck
      COM object i was originally trying to modify
      Dim $oPPT, $oPres $oPPT = ObjCreate("PowerPoint.Application") $oPPT.Visible = True $oPres = $oPPT.Presentations.Read Water's code below (0.1% modified)
      #include <File.au3> #include "PowerPoint.au3" #include <misc.au3> Global $sFile = "C:\temp\presentation.pptx" Global $sString2Search = "<username>", $sString2Replace = "Password", $iReplaceOnce = 1, $sFullLogFile = "C:\temp\pptxlog.txt" _ProcessPpt($sFile) Func _ProcessPpt($sFile) $oApp = _PPT_PowerPointApp() Local $bChange = False Local $oInterface = $oApp.Presentations Local $oPresentation = $oInterface.Open($sFile, False, False, False) If @error Then _FileWriteLog($sFullLogFile, "E Error " & @error & " opening File " & $sFile) Return SetError(1, 0, 0) EndIf ;it does not even open my file and from here not sure how to read the text and replace it EndFunc ;==>_ProcessPpt  
    • Smigacznr1
      By Smigacznr1
      I'm writing Outlook pst cleaner and now I'm stuck. Compiled script is crashing with OS crash message. When I tryied to run script from editor it's exiting itself (mabye it's some type of crash?) always when it's processing on 4-rd pst file. Here is my code:
      #include <OutlookEX.au3> #include <Date.au3> #include <File.au3> #include <Array.au3> _cleanOutlook("Administrator") _cleanOutlook("Admin") Exit Func _cleanOutlook($user) $foldery = "Wiadomości-śmieci#?SPAM#?Junk E-mail#?Elementy usunięte#?Deleted Items" $tab_folderow = StringSplit($foldery, "#?", 1) $tab_pst = _FileListToArrayRec("c:\users\" & $user, "*.pst", 1+4+8, 1, 0, 2) ;~ _ArrayDisplay($tab_pst) For $d = 1 To UBound($tab_pst) -1 Step +1 $outlook = _OL_Open(True) _OL_Close($outlook, True) $outlook = _OL_Open() Local $aStores = _OL_StoreGet($outlook) ;~ _ArrayDisplay($aStores) For $i = 1 to $aStores[0][0] If $aStores[$i][4] = True Then ;~ ConsoleWrite(@CRLF & "zamykam pst 2") _OL_PSTClose($outlook,$aStores[$i][0]) EndIf Next ;~ _OL_PSTAccess($outlook, "C:\Users\Administrator\Desktop\cos.pst") _OL_PSTAccess($outlook, $tab_pst[$d]) ConsoleWrite(@CRLF & $tab_pst[$d]) ;~ $tab_struktury = _OL_FolderTree($outlook, "*", 10) ;~ If @error Then ;~ ContinueLoop ;~ EndIf ;~ _ArrayDisplay($tab_struktury) $tab_ktory_pst = _OL_PSTGet($outlook) ;~ _ArrayDisplay($tab_ktory_pst) For $a = 0 To UBound($tab_ktory_pst) -1 Step +1 If $tab_ktory_pst[$a][2] = $tab_pst[$d] Then ;~ MsgBox(0, "", $tab_ktory_pst[$a][0]) $nazwa_bazy_pst = $tab_ktory_pst[$a][0] EndIf Next ;~ MsgBox(0, "", UBound($tab_folderow)) ;~ _ArrayDisplay($tab_folderow, $tab_pst[$d]) ConsoleWrite(@CRLF & "przed while") $a = 0 While $a < 2 ConsoleWrite(@CRLF & "while 1") For $b = 1 To UBound($tab_folderow) -1 Step +1 ConsoleWrite(@CRLF & "for 1") $tab_struktury = _OL_FolderTree($outlook, $nazwa_bazy_pst) ;~ _ArrayDisplay($tab_struktury, $nazwa_bazy_pst) ;~ $folder = _OL_FolderAccess($outlook, StringTrimLeft($tab_struktury[0], 2) & "\" & $tab_folderow[$b]) $folder = _OL_FolderAccess($outlook, $nazwa_bazy_pst & "\" & $tab_folderow[$b]) ;~ ConsoleWrite(@CRLF & "eeee") If @error Then ;~ MsgBox(0, "", "\\" & $nazwa_bazy_pst & "\" & $tab_folderow[$b] & @CRLF & @error) ConsoleWrite(@CRLF & "przechodze do kolejnego " & $b+1) ContinueLoop EndIf ;~ _ArrayDisplay($folder, $nazwa_bazy_pst) ConsoleWrite(@CRLF & $tab_folderow[$b]) If $tab_folderow[$b] = "Deleted Items" Or $tab_folderow[$b] = "Elementy usunięte" Then ConsoleWrite(@CRLF & "usuwam kosze") _OL_FolderDelete($outlook, $folder[1], 1) _OL_FolderDelete($outlook, $folder[1], 2) _OL_FolderDelete($outlook, $folder[1], 3) _OL_FolderDelete($outlook, $folder[1], 4) ;~ _OL_FolderDelete($outlook, $folder[1], 5) EndIf If $a = 0 Then $tab_maile = "" $data_dzis = @YEAR & "/" & @MON & "/" & @MDAY & " 00:00" ;~ $data_dzis = "2017/01/31 00:00" $data_szukana = _DateAdd("D", "-3", $data_dzis) $tab_maile = _OL_ItemFind($outlook, $folder[1], $olMail, "[Received]<'" & StringReplace($data_szukana, "/", "-") & "'", "", "", "EntryID", "", 1) If @error Then ContinueLoop EndIf ;~ If UBound($tab_maile) > 1 Then ;~ _ArrayDisplay($tab_maile) ;~ EndIf If UBound($tab_maile) > 1 Then For $c = 1 To UBound($tab_maile) -1 Step +1 ;~ ConsoleWrite(@CRLF & "usuwam stare maile") _OL_ItemDelete($outlook, $tab_maile[$c][0], "", False) Next EndIf EndIf Next $a = $a + 1 WEnd ;~ ConsoleWrite(@CRLF & "pokazuje") ;~ $folder[1].Display $olFolderInbox.Display ;~ _OL_PSTClose($outlook, $olFolderInbox) ;~ If @error Then ;~ MsgBox(0, "", @error) ;~ EndIf Local $aStores = _OL_StoreGet($outlook) ;~ _ArrayDisplay($aStores) For $i = 1 to $aStores[0][0] If $aStores[$i][4] = True Then ;~ ConsoleWrite(@CRLF & "zamykam pst 1") _OL_PSTClose($outlook,$aStores[$i][0]) EndIf Next ;_OL_PSTClose($outlook, $folder[1]) _OL_Close($outlook, True) If @error Then MsgBox(0, "", @error) EndIf ConsoleWrite(@CRLF & "zamykam") ProcessWaitClose("outlook.exe", 30) ProcessClose("outlook.exe") Next EndFunc  
      Outlook and OS is updated. I'm usinn OutlooEX in ver. 1.3.1.0
      Any ideas?
       
    • Gowrisankar
      By Gowrisankar
      Dear members of the forum,
      I'm new to AutoIt and I'm having a good time exploring and enjoying the features of AutoIt.
      For one of my tasks, I've to open few particular mails from outlook based on subject of the mails and then print the mails. Can someone please guide me how to do it?
      My question could be very silly for experts. But I'm just a beginner. Kindly advice.
      Thanks and regards,
      Gowrisankar R.
    • water
      By water
      Anyony interested in a function to retrieve the Outlook mailbox quotas for Exchange mailboxes?
      If yes, then this function could be added to the OutlookEX UDF.
      Result could look like (will later be returned in an array):
       
    • ur
      By ur
      I wrote a macro for outlook to send an email.
      Till yesterday it worked, don't know why it is not working today
      I am getting below error when I ran the macro.