LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rich Text Email Message Control

Hi!

 

Been on a haitus in LV programming and now, I'm back in doing some LV codes, and it feels great! I am on a bit of a slump as I wanted to send a emails in labview but I wanted that the body of the email is in rich-text, be able to change font colors, size or style as well as add images in the body like gmail or yahoomail. I'm wondering if anybody has figured out how to do it, or maybe I need to create a code using the Rich Text .net control? I have 2 work around in mind but maybe anyone have other brilliant ideas to share, would gladly take it.

 

So my 2 workwound would be:

1. Open MS Word in LabVIEW (I am having difficulty figuring out opening MSWord in an ActiveX Container), then save the document as a webpage, then I'll copy the HTML source code and then send the html code using the SMTP vis. I was able to figure the part from saving document until sending of the html code using SMTP vis but the opening of MS Word in LabVIEW is quite tricky. I want MSWord to open in LV, like how I can open the browser in LV.

 

2. Use the Rich-Text Control and create a program that can programatically change the font color, style, size etc on the fly.

 

I would prefer to use the second option as I wanted to do everything in the LV environment. Has anybody tried doing a Rich-Text Control with Edit tools on the fly?

 

Looking forward to your insights!

 

Cheers to all and a happy new year!

0 Kudos
Message 1 of 5
(3,573 Views)

There are several examples of using a Rich Text ActiveX control but I admit I've never used them in a real program yet.

 

http://digital.ni.com/public.nsf/allkb/7CFE9838693EFF53862575ED005770FA

 

I've sent emails using LabVIEW that have custom formatting but they are in HTML format.  I'm not sure how easy it would be to allow the user to make a rich text message, then convert it to HTML and then send that.

0 Kudos
Message 2 of 5
(3,529 Views)

Hi Hoovahh!

 

Thanks for the insight and the link! I was wondering, when you said send you sent emails that have custom foratting in html format, you mean it is in the html code format? I am also thinking of the conversion of the rich text to html.. guess it will be days of intensive programming and thinking for me. 😄

0 Kudos
Message 3 of 5
(3,507 Views)

So here is one example of what I've been doing latelly.  We have a lab monitoring system that logs events into a SQLite database.  Once a day a query is made to the database to see what events happened in the last 24 hours and sends out an email summary.  At first I was going to send it as an image of a table that was an attachment in the email but then things had scaling issues, and wouldn't look nice on your phone if that is where you read the email.  Also for a table it would be a relativly large email.  So I looked into sending the email as HTML and it seems to work.  Here is the body of an email I send as a string which creates a table.  This string is created based on the database query.

 

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
    border: 1px solid black;
    border-collapse: collapse;
}
th, td {
    padding: 5px;
    text-align: left;
}
</style>
</head>
<body>

<h2>Summary from<br>2017-01-04 08:50:19<br>to <br>2017-01-05 08:50:19</h2>

<table style="width:100%">
  <tr>
    <th>Time</th>
    <th>Device</th>
    <th>Channel</th>
    <th>Computer</th>
    <th>Status</th>
  </tr>
<tr>
    <td>2017-01-05 08:49:01</td>
    <td>Device 3</td>
    <td>Channel 1</td>
    <td>IP 3</td>
    <td bgcolor="64FF00">Testing</td>
</tr>
<tr>
    <td>2017-01-05 08:49:01</td>
    <td>Device 3</td>
    <td>Channel 1</td>
    <td>IP 3</td>
    <td bgcolor="FF0000">Halted</td>
</tr>
<tr>
    <td>2017-01-05 08:49:51</td>
    <td>Device 3</td>
    <td>Channel 1</td>
    <td>IP 3</td>
    <td bgcolor="FFFFFF">Offline</td>
</tr>
<tr>
    <td>2017-01-05 08:50:11</td>
    <td>Device 3</td>
    <td>Channel 2</td>
    <td>IP 3</td>
    <td bgcolor="88EEFF">Done</td>
</tr>
<tr>
    <td>2017-01-05 08:50:11</td>
    <td>Device 3</td>
    <td>Channel 1</td>
    <td>IP 3</td>
    <td bgcolor="88EEFF">Done</td>
</tr>
</table>
</body>
</html>
Spoiler

Summary from
2017-01-04 08:50:19
to
2017-01-05 08:50:19

Time Device Channel Computer Status
2017-01-05 08:49:01 Device 3 Channel 1 IP 3 Testing
2017-01-05 08:49:01 Device 3 Channel 1 IP 3 Halted
2017-01-05 08:49:51 Device 3 Channel 1 IP 3 Offline
2017-01-05 08:50:11 Device 3 Channel 2 IP 3 Done
2017-01-05 08:50:11 Device 3 Channel 1 IP 3 Done

The hidden table above is what the HTML text creates.  I then sent this string using a gmail account using the code posted here, or here.  The result is a nice HTML table in an email that can be viewed and scales on other devices.  My suggestion for you is to find a way to have a rich text editor, that the user can put text and formatting into, and then when they click Send, it actually saves that as an HTML in a temp file, and then you read that temp HTML file and send it.

Message 4 of 5
(3,492 Views)

That is one great solution. I'll try out your suggestion. Thanks a lot Hooovahh! Cheers!

0 Kudos
Message 5 of 5
(3,483 Views)