function fun_mail2me(app,mailboxSet)
% mailboxSet strcut结构
% 包含变量:Sender/Server/Recipients/Password/Title/Content
setpref('Internet','E_mail',mailboxSet.Sender);
setpref('Internet','SMTP_Server',mailboxSet.Server);
setpref('Internet','SMTP_Username',mailboxSet.Sender);
setpref('Internet','SMTP_Password',mailboxSet.Password);
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.auth','true');
if ~isfield(mailboxSet,'Title');mailboxSet.Title = strcat(datestr(now,...
'yyyy-mm-dd HH:MM:SS'),32,'已完成通知');end
% 循环发送信息 以“;”作为分隔符
Recipients = split(mailboxSet.Recipients,';');
for ii = 1 : length( Recipients )
if ~isempty( cell2mat(Recipients ( ii )))
try
sendmail(Recipients( ii ),mailboxSet.Title,mailboxSet.Content);
disp(strcat(datestr(now,'yyyy-mm-dd HH:MM:SS'),32,'已完成通知'));
catch
disp('ERROR!!! 通知出错') ;
end
end
end
end
网友评论