MATLAB including a table within the bodytext of an email

I am trying to get matlab to include a table in the bodytext of an email that I am trying to send.
I can't find any obvious way of doing it after searching the web and was wondering if somebody had a function that the could share or if it is even possible at all?
thanks

Answers (1)

After a brief look at the code of sendmail (use edit sendmail to look at it yourself), I can say that it is only designed to send plain text e-mails. You would need an html or rtf email to embed a table in the body, so it's not possible.
Note that sendmail uses the java mail API, which as far as I understand support sending html emails, so you could actually write your own version with support for html. It's probably not that straightforward if you're not familiar with the javax.mail API.
Possibly, you could make a copy the code of sendmail (with a new name) and edit that copy so the lines:
if ~isempty(charset)
msg.setText(body, charset);
else
msg.setText(body);
end
read instead:
if ~isempty(charset)
msg.setText(body, charset, 'html');
else
msg.setText(body, '', 'html'); %not sure an empty charset will work
end
and pass your message text as a cell array of strings that represent the html content of your email (with an html table for your table).
No idea if that would work correctly.

Tags

Asked:

on 13 Apr 2015

Answered:

on 13 Apr 2015

Community Treasure Hunt

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

Start Hunting!