Generate HTML Formatted e-mail?
mludviksen
Posts: 18
Hi. Just wondering if anyone has tried (with success) to create an HTML formatted e-mail from an AMX Netlinx Master. I have some log files I would like to send on a daily basis, and they would look much nicer if I could format the output with HTML.
Thanks!
Mark
Thanks!
Mark
0
Comments
I tried the following using GMail, and it's not working as expected. Perhaps I'm doing something wrong...
When I look at the original e-mail source via Google's webmail, I see the following:
I'm not sure why that first header showing text/plain is showing up there, but that seems to be dictating the format of the e-mail. Any ideas on how to override that?
Thank you for your help!
Mark
Maybe I'm missing something but by what your code says your message ends up being:
I'm guessing you're trying to put in line feeds. Here's what that should look like:
I guess the first thing I'd try in your case is to leave off "MIME-Version: 1.0" from the text you are sending, and also add two line feeds after the type like so: "'Content-Type: text/html',10,10" and hope that the email client takes this as an override.
If that doesn't work you may be out of luck.
Eric,
Thanks for the reply. I think the variable cEMailBody ended up containing what I expected based on what the message contained - but I didn't do it in the most efficient way. Honestly, I wasn't sure how to handle continuing a long line of code onto another line in Netlinx. Some languages require a continuation character like a "_", and I didn't know how to handle it so I punted. I basically had multiple lines of code that said variable = "a", variable = variable + "b", so then variable = "ab".
I think the question is whether or not the SMTP_SEND automatically inserts the text/plain header and if there is any way to override it. I would like to use GMail, so I'm stuck with TLS.
Mark
Greg,
I tried what you suggested, but unfortunately it did not override the settings. The e-mail I received showed the format text and HTML as the text of the message. Here's what the "original" (raw) message looks like from the GMail Web App:
I found some open source SMTP/TLS code online, but it sure would be nice if AMX had the functionality built-in.
http://www.matrixssl.org/index.html
http://www.codeproject.com/Articles/98355/SMTP-Client-with-SSL-TLS
Mark
For email purposes, this is probably do-able, since emails don't have to happen at real-time speeds. But this would definitely require using java/duet because the netlinx language itself might spend forever trying to handshake a TLS connection and timeout before it can even begin. (Assuming you were determined enough to attempt implementing the algorithm that way :-)
There is some degree of TLS support in Duet, but it's not documented, so it may break when things change - like a lot of my stuff did when the firmware went from 3 to 4.
Hey Greg,
I'm working with this module as well, however my problem is my timestamp is incorrect. I am sending emails at 1pm, and it's showing it was sent at 6:00am. Is this something in the module I can correct?
Thank you,
Matt
If you have the source (mine is an include file called EmailOut.axi), you can just edit the part where it adds the Date: header like:
"Date: Fri, 06 Mar 2015 12:05:50 -0600"
and make sure it is appending the correct offset from UTC.
In my file it is on line 178 and it doesn't actually include the offset at all:
So you could change it to: to get a -6 hour offset from UTC propagated along to the recipient.
If you are using the i!-EquipmentMonitorOut.axi ( http://www.amx.com/techcenter/downloadConfirm.asp?fn=/assets/applicationFiles/i!-EquipmentMonitorSetup.exe ) there is a function you can call to set your timezone in the email called SmtpSetTimeOffset(CHAR
Offset[]) - just pass it in like SmtpSetTimeOffset("'-0600'")
Anyone ever have luck creating an .ICS file and attaching it via the email? I'd like to attach a meeting invite as my email attachment.
Ahh, interesting. I guess I won't waste anymore time on this if I cannot attach the .ics file with my email. :-/