我已将输出分配给函数“ Email_Output”,但始终收到错误消息。
答案 0 :(得分:0)
首先,正如Ander Biguri已经说过的那样,函数定义应该在输出参数之前,因此,在您的情况下,function Email_output = EmailScript0(to, subject, body, attachments)
是正确的。
第二,您正在EmailScript0本身的函数定义中调用EmailScript0,它将无法正常工作。
要使用MATLAB通过Outlook发送电子邮件,有一个示例in this MATLAB Answers。
function sendolmail(to,subject,body,attachments)
% Codes are cited from https://www.mathworks.com/matlabcentral/answers/94446
% Sends email using MS Outlook. The format of the function is
% Similar to the SENDMAIL command.
% Create object and set parameters.
h = actxserver('outlook.Application');
mail = h.CreateItem('olMail');
mail.Subject = subject;
mail.To = to;
mail.BodyFormat = 'olFormatHTML';
mail.HTMLBody = body;
% Add attachments, if specified.
if nargin == 4
for i = 1:length(attachments)
mail.attachments.Add(attachments{i});
end
end
% Send message and release object.
mail.Send;
h.release;
您可以从MATLAB Command Window调用此函数。
sendolmail('YOUR_ADDRESS@XXX.com','Trial', '<a href="https://www.google.com/">a link</a>','');