SendMail()

Summary

Initiates a mail program and composes an e-mail with a window as a file attachment.

Changes

Added dialog option in Version 6.0/2012.

Syntax

SendMail(array options)

Option Type Contents
to Array Strings or arrays with e-mail addresses of to: recipients
cc Array Strings or arrays with e-mail addresses of cc: recipients
subject String Subject header
body String Body of message
attach String Window name of the form "window type|window name"
dialog Boolean If "True" (default) the message is displayed; if "False" the message is not displayed, but immediately sent.

Notes

  • The mail program must be initialized in the MAPI section of the win.ini file.

  • A missing option means that part of the e-mail is blank. Even if there are no options, calling SendMail() will launch your mail program.

  • An element in the array for the to or cc option can either be a stringcontaining an e-mail address, or an array containing two strings, an e-mail address and a display name for that e-mail address. Some e-mail programs require a display name.

  • The window must be a map window. It is sent as a .map file. The recipients will need to have the files referred to in the .map file.

  • Use the dialog option to send a message from a script without it being displayed first.

Example

opts = {}
opts.to = {"info@caliper.com"}
opts.cc = {"sales@caliper.com", {"support@caliper.com", "Tech Support"}}
opts.subject = GetMap()
opts.body = "Here is the latest version of the map. Any comments?"
opts.attach = "Map|" + GetMap()
opts.dialog = "False"
SendMail(opts)

Error Codes

Error Type Meaning
NotFound MAPI information cannot be found in the win.ini, or the mapi32.dll is not present
Escape The user escaped out of the mail program
Error The mail program failed in an unspecified way

See Also

Function Summary
LaunchProgram() Starts a Windows program