function emailresults(address,filename) % This program will email the results from a workspace or m-file to the % address as placed in the input. For example, if you save your workspace % as results.mat and your email address is myemail@yahoo.com then your % inputs should be 'myemail@yahoo.com' and 'results.mat'. Written by % Philip Shaw, Fordham University. % Define these variables appropriately: %address = input('Please enter your email address so Matlab can send you the results: ', 's'); %filename=input('Enter the file name you would like to attach: ', 's'); mail = 'resultsfrommatlab@gmail.com'; %Your GMail email address password = 'choleskyrules'; %Your GMail password % Then this code will set up the preferences properly: setpref('Internet','E_mail',mail); setpref('Internet','SMTP_Server','smtp.gmail.com'); setpref('Internet','SMTP_Username',mail); setpref('Internet','SMTP_Password',password); props = java.lang.System.getProperties; props.setProperty('mail.smtp.auth','true'); props.setProperty('mail.smtp.socketFactory.class', 'javax.net.ssl.SSLSocketFactory'); props.setProperty('mail.smtp.socketFactory.port','465'); % Send the email. Note that the first input is the address you are sending the email to sendmail(address,'Matlab is done','Hello! Please find your results attached!',filename)