Send Outlook email by using .NET
Afficher commentaires plus anciens
Hello,
I'm trying to send Outlook email through .NET API. Any help on coding would be highly appreciated. Below is the "known" code by using COM and actxserver, but as I'm facing some other issues, I'd like to see if I can fix that probelm by switching to .NET.
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;
Here's how far I'm at the momment :)
dotnetenv("framework")
h=NET.addAssembly('microsoft.office.interop.outlook');
Now I'd need to dublicate the rest of the code, which I haven't succeeded in yet.
Here's a link to Microsoft's namespace for Outlook.
Thanks in advance,
Tero
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Call Web Services from MATLAB Using HTTP dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
