Programming Previous page   Next Page

Sending E-Mail

To send an e-mail from within MATLAB, use the sendmail function. You can also attach files to an e-mail, which lets you mail files directly from MATLAB. To use sendmail, you must first set up your e-mail address and your SMTP server information with the setpref function.

The setpref function defines two mail-related preferences:

You should be able to find your outgoing SMTP server address in your e-mail account settings in your e-mail client application. You can also contact your system administrator for the information.

Once you have properly configured MATLAB, you can use the sendmail function. The sendmail function requires at least two arguments: the recipient's e-mail address and the e-mail subject:

You can supply multiple e-mail addresses using a cell array of strings, such as:

You can also specify a message body with the sendmail function, such as:

In addition, you can also attach files to an e-mail using the sendmail function, such as:

You cannot attach a file without including a message. However, the message can be empty.You can also attach multiple files to an e-mail with the sendmail function, such as:

Example -- Using the sendmail Function

The following example sends e-mail with the retrieved Web page archive attached if it contains any matches for the specified word:


Previous page  Creating and Uncompressing Zip Archives Performing FTP File Operations Next page

© 1994-2005 The MathWorks, Inc.