Lua
Lua
Permanently Delete a Specific GMail Message
See more GMail REST API Examples
Immediately and permanently deletes the specified message. This operation cannot be undone. (This is not the same as moving a message to Trash.)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()
http.auth_token = "GMAIL-ACCESS-TOKEN"
-- The id of the GMail message to delete.
local id = "1669cc9a926bb8c1"
local userId = "me"
http:set_url_var("userId", "me")
http:set_url_var("id", id)
-- Delete the email.
local url = "https://www.googleapis.com/gmail/v1/users/{$userId}/messages/{$id}"
local responseStr = http:quick_delete_str(url)
if not http.last_method_success then
print(http.last_error_text)
return
end
print("status = " .. http.last_status)
-- A 204 response indicate success.
-- It is common for HTTP DELETE operations to respond with a 204 status code with an empty body for success.
-- You'll find many REST APIs follow this custom..
if http.last_status ~= 204 then
print(responseStr)
print("Failed.")
return
end
print("Message deleted!")