23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6 Data Import and Export<br />

Once you have properly configured <strong>MATLAB</strong>, you can use the sendmail<br />

function. The sendmail function requires at least two arguments: the<br />

recipient’s e-mail address and the e-mail subject:<br />

sendmail('recepient@someserver.com', 'Hello From <strong>MATLAB</strong>!');<br />

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

sendmail({'recepient@someserver.com', ...<br />

'recepient2@someserver.com'}, 'Hello From <strong>MATLAB</strong>!');<br />

You can also specify a message body with the sendmail function, such as:<br />

sendmail('recepient@someserver.com', 'Hello From <strong>MATLAB</strong>!', ...<br />

'Thanks for using sendmail.');<br />

In addition, you can also attach files to an e-mail using the sendmail function,<br />

such as:<br />

sendmail('recepient@somesever.com', 'Hello from <strong>MATLAB</strong>!', ...<br />

'Thanks for using sendmail.', 'C:\yourFileSystem\message.txt');<br />

You cannot attach a file without including a message. However, the message<br />

can be empty. You can also attach multiple files to an e-mail with the<br />

sendmail function, such as:<br />

sendmail('recepient@somesever.com', 'Hello from <strong>MATLAB</strong>!', ...<br />

'Thanks for using sendmail.', ...<br />

{'C:\yourFileSystem\message.txt',...<br />

'C:\yourFileSystem\message2.txt'});<br />

Example — Using the sendmail Function<br />

The following example sends e-mail with the retrieved Web page archive<br />

attached if it contains any matches for the specified word:<br />

% The urlread function loads the contents of the Web page into<br />

the % <strong>MATLAB</strong> workspace.<br />

recentFile =<br />

urlread('http://www.mathworks.com/matlabcentral/fileexchange/<br />

6-120

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!