Lua Requires Chilkat v9.5.0.68+
Lua
Outlook -- Delete Folder
See more Outlook Examples
Deletes an email folder.This example applies to: Exchange Online | Office 365 | Hotmail.com | Live.com | MSN.com | Outlook.com | Passport.com
Chilkat Lua Downloads
local chilkat = require("chilkat")
local success = false
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local http = chilkat.Http.new()
-- Use your previously obtained access token here:
http.auth_token = "MICROSOFT_GRAPH_ACCESS_TOKEN"
-- This example will delete the folder /Inbox/abc/subFolderC
-- Get the existing folder ID from the folder map created by this example
local htFolderMap = chilkat.Hashtable.new()
local sbMap = chilkat.StringBuilder.new()
sbMap:load_file("qa_data/outlook/folderMap.xml", "utf-8")
htFolderMap:add_from_xml_sb(sbMap)
local existingFolderId = htFolderMap:lookup_str("/Inbox/abc/subFolderC")
if not htFolderMap.last_method_success then
print("Folder ID not found")
return
end
http:set_url_var("folder_id", existingFolderId)
local resp = http:quick_delete_str("https://graph.microsoft.com/v1.0/me/mailFolders/{$folder_id}")
if not http.last_method_success then
print(http.last_error_text)
return
end
-- A 204 response (with no response body) indicates success.
if http.last_status == 204 then
print("Folder deleted.")
else
print("Folder not deleted.")
print(resp)
end