Send Emails from GUI
7 ビュー (過去 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!