Send Emails from GUI

7 Ansichten (letzte 30 Tage)
Zainab Riyadh
Zainab Riyadh am 23 Mai 2023
Kommentiert: Adam Danz am 24 Mai 2023
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' });

Antworten (1)

the cyclist
the cyclist am 24 Mai 2023
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.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by