MailExecute

MailExecute[cmd,target]

executes the mail command cmd on the mail item or folder given.

Details

  • Possible commands include:
  • "Delete"delete a mail item
    "Flags"give the list of flags for a mail item
    "SetFlags"{"flag1",}set flags for a mail item
    "ClearFlags"clear all flags for a mail item
    "ClearFlags"{"flag1",}clear specified flags for a mail item
    "Copy"MailFolder[]copy to the specified target folder
    "Create""name"create a new named folder in the specified folder
    "Expunge"permanently remove all deleted items from a mail folder
  • Possible targets depend on the command given.
  • For commands operating on mail items, MailExecute[cmd,{MailItem[],MailItem[],}] operates on multiple items.
  • For the "Create" command, the target can be a MailServerConnection object, specifying the creation of a new folder in the root.
  • For "Delete" and "Expunge", MailExecute returns a Success or Failure object.
  • Commands that manipulate flags return the final list of flags for a mail item, or an association of results for a list of mail items.
  • "Copy" returns the resulting MailItem object. "Create" returns the resulting MailFolder object.

Examples

open allclose all

Basic Examples  (1)

Connect to a server:

In[1]:=
Click for copyable input
Out[1]=

Open the "Example" folder:

In[2]:=
Click for copyable input
Out[2]=

Get the first (oldest) email from the folder:

In[3]:=
Click for copyable input
Out[3]=

List the flags set on this email:

In[4]:=
Click for copyable input
Out[4]=

Mark the email as unread:

In[5]:=
Click for copyable input
Out[5]=

Applications  (1)

Neat Examples  (1)

See Also

MailServerConnect  MailItem  MailFolder  SendMail  ServiceExecute

Introduced in 2018
(11.3)