Send Emails from GUI
8 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a GUI where I used exportapp to save a uifigure to pdf file :
exportapp(fig1, 'info1.pdf')
Then, I found the following function file in Matlab, which can send emails. I tried using it in a Script file to send a pdf file and it worked. However, when I shift to GUI and try using the function to send the pdf generated from exportapp, it doesn't work. Though, I get the pdf saved on my pc.
This is the function file:
function sendolmail(to,subject,body,attachments)
%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;
end
This code is used to send the email:
sendolmail('Email Address','Summary Report',{'C:\info1.pdf' });
0 个评论
回答(1 个)
the cyclist
2023-5-24
I don't know the answer to your question, but you might have better luck using the MATLAB-supplied sendmail function, rather than that quite old File Exchange function.
1 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!