MailExecute

MailExecute[cmd,target]

executes the mail command cmd on the target mail server connection, folder, file or item(s).

Details

  • Possible commands cmd for a mail item target include:
  • "Delete"delete a mail item
    "Flags"list 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 mail item to the specified folder
    "Upload"MailFolder[]upload mail item to the specified folder
  • Possible commands cmd for a mail file target include:
  • "UploadEMLFile"MailFolder[]upload "EML" type files to the specified folder
    "UploadMBOXFile"MailFolder[]upload "MBOX" type files to the specified folder
  • Possible commands cmd for a mail folder target include:
  • "Expunge"permanently remove all deleted items from a mail folder
    "Download"download all messages in the specified folder
    "MarkFolderRead"mark the entire mail folder as read
    "Create""name"create a folder using "name" in specified folder
  • Possible commands cmd for a mail server connection target include:
  • "Create""name"create a folder using "name" in the server root directory
  • For commands operating on mail items, MailExecute[cmd,{MailItem[],MailItem[],}] operates on multiple items.
  • MailExecute returns Success or Failure for the following commands: "Delete", "Upload", "UploadEMLFile", "UploadMBOXFile" and "Expunge".
  • 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" and "MarkFolderRead" return the resulting MailFolder object.
  • "Download" returns the resulting local File object.

Examples

open allclose all

Basic Examples  (1)

Connect to a server:

Open the "Example" folder:

Get the first (oldest) email from the folder:

List the flags set on this email:

Mark the email as unread:

Scope  (1)

Connect to a mail server:

Open a folder:

Download all emails from the folder:

List the files:

Import one email as an Association and list its keys:

Applications  (1)

You can use MailExecute to permanently delete spam email messages. Connect to a mail server:

Open the "Trash" folder:

Get three messages from the folder:

Mark the messages as deleted:

Count messages marked for deletion:

Permanently delete the messages:

Neat Examples  (1)

Connect to a server:

Open the "Junk" folder:

Search the folder for all items that mention the word "free":

Number of emails found by the mail search:

Delete the emails:

Check that all the flags include "Deleted":

Wolfram Research (2018), MailExecute, Wolfram Language function, https://reference.wolfram.com/language/ref/MailExecute.html (updated 2020).

Text

Wolfram Research (2018), MailExecute, Wolfram Language function, https://reference.wolfram.com/language/ref/MailExecute.html (updated 2020).

CMS

Wolfram Language. 2018. "MailExecute." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/MailExecute.html.

APA

Wolfram Language. (2018). MailExecute. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MailExecute.html

BibTeX

@misc{reference.wolfram_2024_mailexecute, author="Wolfram Research", title="{MailExecute}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/MailExecute.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_mailexecute, organization={Wolfram Research}, title={MailExecute}, year={2020}, url={https://reference.wolfram.com/language/ref/MailExecute.html}, note=[Accessed: 21-November-2024 ]}