Send Emails from GUI

7 ビュー (過去 30 日間)
Zainab Riyadh
Zainab Riyadh 2023 年 5 月 23 日
コメント済み: Adam Danz 2023 年 5 月 24 日
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' });

回答 (1 件)

the cyclist
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.

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by