MATLAB Answers

MATLAB email body include text and a table

조회 수: 6(최근 30일)
Fragkiskos Nikolakis
Fragkiskos Nikolakis 2021년 5월 20일
댓글: Fragkiskos Nikolakis 2021년 5월 21일
Hello everyone,
I would like to include into an email body apart from text, also a table.
For example:
This is a test email
'Alberta' '2020-07-20 00:00:00.0' '2021-05-03 00:00:00.0' 'no action needed' 'no action needed'
'Aristarchos' '2017-09-14 00:00:00.0' '2020-12-12 00:00:00.0' 'no action needed' 'action needed'
'Balos' '2018-05-22 00:00:00.0' '2020-12-20 00:00:00.0' 'no action needed' 'no action needed'
I tried to modify the sendmail function with below code:
~isempty(charset)
msg.setText(body, charset, 'html');
else
msg.setText(body, '', 'html'); %not sure an empty charset will work
end
but the result was that I couln't add the text only the table but not with the required format but simple single rows as per below:
Alberta
Aristarchos
Balos
2020-07-20 00:00:00.0
2017-09-14 00:00:00.0
2018-05-22 00:00:00.0
2021-05-03 00:00:00.0
2020-12-12 00:00:00.0
2020-12-20 00:00:00.0
no action needed
no action needed
no action needed
no action needed
action needed
no action needed
How can I achieve the required format?
Thank you in advance!!

채택된 답변

Geoff Hayes
Geoff Hayes 2021년 5월 20일
  • The sendmail function does not support HTML-formatted messages. However, you can send HTML files as attachments.
So you might want to try converting your cell array into an HTML table and attach that to your message. Else, you could try converting each row of your cell array into a single string and include that in your message body (assuming that the text is no longer than 75 characters, I think that it all should be written to one line in the message).

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by