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 (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.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 (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.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 (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.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 (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.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

#10 ·  Posted

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 (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.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

#11 ·  Posted

:)

Now it works

Thanks a million

Share this post


Link to post
Share on other sites

#12 ·  Posted

:)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2016-08-18 - Version 1.4.6.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2016-12-04 - Version 1.2.2.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

    • ur
      Suppress Prompts with Outlook
      By ur
      Through below script I am able to send mail with the Outlook installed in my machine.
       
      But I am getting below prompt whenever I ran this script,by Outlook.
      Can anyone suggest how to suppress this.
      #include <MsgBoxConstants.au3> ; Counting the number of open shell windows Local $oShell = ObjCreate("Outlook.Application") ; Get the Windows Shell Object If IsObj($oShell) Then $Mail = $oShell.CreateItem(0) $Mail.To = "dponnada@erwin.com" $Mail.Subject = "Action" $Mail.Body ="Pay rise please" $Mail.Send() EndIf  

    • Vivaed
      List files in folder, delete all but newest version
      By Vivaed
      I am trying to read all the files in a folder, then whatever file is newest, keep only that one and delete the rest.
      Example files:  (these all have version numbers embedded in them, I dont want to rely on the file name)
      Faint.exe
      Faint-v2.0.exe
      Faint-v3.0.exe
      Faint-v4.0.exe
       
      What I have so far:
      #include <File.au3> RemoveOldFiles() ConsoleWrite(FileGetVersion("C:\WB Resources\FAINT_DONT_LINK_THESE\Faint-v4.0.0.exe") &@CRLF) Func RemoveOldFiles() Local $aFileList = _FileListToArray("C:\WB Resources\FAINT_DONT_LINK_THESE\", "*.exe",$FLTA_FILES) For $i = 0 To UBound($aFileList) - 1 $aFileVersion = FileGetVersion($aFileList[$i]) ConsoleWrite($aFileList[$i] & @CRLF) ConsoleWrite($aFileVersion & @CRLF) Next EndFunc OUTPUT: >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\bot\ownCloud\WellBeats\Delete Old Files\delete-test.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop 3 0.0.0.0 a.exe 0.0.0.0 b.exe 0.0.0.0 Faint-v4.0.0.exe 0.0.0.0 4.0.0.18 <-- This is the correct file version.... +>07:34:26 AutoIt3.exe ended.rc:0 +>07:34:26 AutoIt3Wrapper Finished. >Exit code: 0 Time: 0.6647 Not sure what I am missing here?
      Thanks!
    • Dent
      [Solved] _OL_ItemSend not sending
      By Dent
      Hi, I have written the following code and although the email is successfully created from a template it just sits in my draft folder without being sent and I can't figure out why?
      #include <OutlookEX.au3> $Email = "test@test.com" $Outlook = _OL_Open() $olItem = _OL_ItemCreate($Outlook, 1, "", "Feedback.oft", "To=" & $Email) _OL_ItemSend($Outlook, $olItem, Default) _OL_Close($Outlook) Place Feedback.oft in the same folder as the script for it to run. Oh and you have to have a working Outlook installation and mail profile set up
      SOLVED changed the 1 to $olMailItem
       
      Feedback.oft
    • Revelation343
      Mailing from Excel/variable storing
      By Revelation343
      Purpose of script: To send emails in Outlook based on data in an excel spreadsheet. From: fields are entered for purposes of sending on behalf of (delegate), copies A2 cell from excel for To: field, Subject field is a static value and entered, returns to excel spreadsheet to read A1 and copy the first name and insert into the body of a template at an insertion point. The From, and the body of the email change based on region, so currently I have 6 different scripts that do essentially the same thing with some minor changes and want to consolidate into one script to save time.
      Question:
      To expedite the process of this and cut down on the amount of scripts, 6 in total I use daily, is it possible for me to somehow add the region to column C in excel, have autoit read column C values per row, and then decide which function, within a master script, to execute and loop this until there is no value in column C field?
      Example spreadsheet:
      Rob | rob@annuity.com |Midwest
      Annie | annie@agency.com | Midwest
      Kyle | kyle@agency.com | MidAtlantic
      Rick | rick@megasales.com | MidAtlantic
      Blank | Blank | Blank |
      Example execution:
      Run Birthday.au3, execute loop part through hotkey
      Reads row 1, C1, value is Midwest, calls Midwest(), script runs as Midwest Birthday.au3 does currently
      Reads row 2, C2, value is Midwest, calls Midwest(), script runs as Midwest Birthday.au3 does currently
      Reads row 3, C3, value is MidAtlantic, calls MidAtlantic(), script runs as MidAtlantic Birthday.au3 currently
      Reads row 4, C4, value is MidAtlantic, calls MidAtlantic(), script runs as MidAtlantic Birthday.au3 currently
      Reads row 5, C5, value is null or blank, ends script through Exit
       
      Everything I have coded in my time in AutoIt has been based mostly on mouse based movements and I don't have variable programming knowledge so I feel like I'm close to understanding how to do this, but the reading/storing variables part is beyond my current skill set. Help is appreciated.
      Mail Merges don't work as delegated in Outlook 07, for those that might be questioning why I just don't do that.
       
      MidAtlantic Birthday.au3
      Midwest Birthday.au3
    • water
      OutlookEX
      By water
      Extensive library to control and manipulate Microsoft Outlook.
      Theads: Development - General Help & Support - Example Scripts - Wiki
      BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort

      KNOWN BUGS (last changed: )