Bugzilla@Mozdev – Bug 25871
Insert html or text from a file
Last modified: 2015-07-09 04:43:35
You need to log in before you can comment on or make changes to this bug.
Hi, One feature that would be awsome is the ability of load the signature content from a .txt or .html file. For people that have the signature use in several places when changing one it would change all, and by the default way that is know i have to go to all thunderbird to change the signature. Thanks for your attencion
Have made any comments about this matther? Thanks
It is possible, as long as the file is locally available (not a web link). Let's draw up some syntax. Since you could insert pretty much anything from a file (and not just a signature) we could go for something like this: %file(type, path)% %file(txt, C:/Test/foo.txt)% %file(html, C:/Test/bar.html)% This could potentially be used for other file types as well. one complication is that for a signature (and html) file you would still expect the internal %variables% to be processed, correct?
Hi, Yes it could be anything like that. I want to be able to load signatures from a local file, but also with the corresponding internal %variables% from smarttemplate4. I have diferente signatures for nem message, reply and forward is the same, and have a header template also and they have both html code and smattemplate variables at the same time. It could be like that or if load from an html file and give the code line for reference for the beginning and end of signature code. The easy way to do it that you think is best.
(In reply to comment #3) > Hi, > > Yes it could be anything like that. > I want to be able to load signatures from a local file, but also with the > corresponding internal %variables% from smarttemplate4. > I have diferente signatures for nem message, reply and forward is the same, and > have a header template also and they have both html code and smattemplate > variables at the same time. > > It could be like that or if load from an html file and give the code line for > reference for the beginning and end of signature code. > > The easy way to do it that you think is best. > I have said the code is in .html, but all the html code can be on a .txt i believe its the same.
(In reply to comment #4) > (In reply to comment #3) > > It could be like that or if load from an html file and give the code line for > > reference for the beginning and end of signature code. > > > > The easy way to do it that you think is best. > > > > I have said the code is in .html, but all the html code can be on a .txt i > believe its the same. > The file type doesn't really matter too much, but you must specify what kind of *content* is in the file using the first parameter: %file(txt, ...)% = the content of the file is interpreted as "text only". line breaks have to be typed in %file(html, ...)% = the content is interpreted as "html". Spaces are collapsed, new lines have to be entered as <br>. You can also use block level elements such as <h1> <h2> <p> <div> etc. or <table> and <style> elements to add css. Use of <header> and <html> tags is not supported.
Created an attachment (id=7967) [details] Signature example
I have uploaded an example of my signature code. The first group is the replacemnt header on reply and forward. The second group os for new messages. The third group is the signature for reply and forward messages. Does it fit the example? Thanks for all your help!
(In reply to comment #7) > I have uploaded an example of my signature code. > > The first group is the replacemnt header on reply and forward. > > The second group os for new messages. > > The third group is the signature for reply and forward messages. > > > Does it fit the example? > > Thanks for all your help! > Yes, can you also upload an archive with the images that you refer to for testing? Also, when the image doesn't work, the "email" line in the first signature is moved to the left (under image place holder). Consider using a invisible <table> or a <div> with style="display: inline-block;" for the text block beside the image instead. Also I believe you have a unicode issue with this line: telemóvel: +351 xxx xxx xxx | telefone: +351 xxx xxx xxx | email: XXXX@XXXX.com In the signature file, do not insert the ó character directly, use a unicode entity instead: http://www.fileformat.info/info/unicode/char/f3/index.htm In HTML, you can use ó for this letter to ensure it not being "garbled" by the recipient's mail clients.
Created an attachment (id=7968) [details] Signature example Signature Example
Created an attachment (id=7969) [details] amb_logo
Created an attachment (id=7970) [details] ambiente
Created an attachment (id=7971) [details] info_amb
Thanks for the correction to my code. I apreciate and i have made all the sugested corrections. I also have uploaded the images as asked. Hope it fits and you can help me out. Thanks
Any development on this subject? Thanks
(In reply to comment #14) > Any development on this subject? > > Thanks > eventually, I will work on this. Just have a lot on my plate at the moment, but I will get around to it. send me an email in a week's time as a reminder
As a reminder for this subject!
Hi! How is the update for this funcionality?
(In reply to comment #17) > Hi! > > How is the update for this funcionality? > ??
(In reply to comment #18) > (In reply to comment #17) > > Hi! > > > > How is the update for this funcionality? > > > > ?? > not yet. At the moment I am focusing on my release of QuickFolders, then more work on ST4 can be next.
(In reply to comment #19) > (In reply to comment #18) > > (In reply to comment #17) > > > Hi! > > > > > > How is the update for this funcionality? > > > > > > > ?? > > > > not yet. At the moment I am focusing on my release of QuickFolders, then more > work on ST4 can be next. > Hi, Any news about this update? Thanks
Created an attachment (id=8042) [details] 0.9.7 prerelease 109 Try this version. syntax: %file(local path)% example: %file(E:\Dev\Mozilla\DEV\SmartTemplate\Test\file\testFile.html)% ---- HTML / text Files ------ The path may only contain ASCII characters! it has to be a local file (I haven't tested network / UNC paths) file extensions: html, htm and txt --- Pictures ---------- If you want to insert an image instead, use the platform agnostic (html) way of defining the path as I am using a simple text replacement at the moment: html = "<img src='file:///" + path + "'\\>"; file extensions: png, apng, jpg, jpeg, jp2k, gif, tif, bmp, dib, rle, ico, svg, webp
This is a possible workaround to what you are actually looking for. %file% is a bit like %sig% in that it inserts the html file in place. However it doesn't currently expand other %variables% (like %sig% does) and also it obviously doesn't replace the default signature, so you will still have to use %sign(none)% to suppress the default signature. I am thinking about whether we should also create a new variable for "re-pointing" the signature file so it overrides the settings in the main mail account settings. something like %sigPath(path)% maybe... I feel this might actually be closer to your ogirinal request (and I only realize it now that I am actually changing the title of this bug).
(In reply to comment #21) > Created an attachment (id=8042) [details] [details] > 0.9.7 prerelease 109 > > Try this version. > > syntax: > %file(local path)% > > example: > %file(E:\Dev\Mozilla\DEV\SmartTemplate\Test\file\testFile.html)% > > ---- HTML / text Files ------ > The path may only contain ASCII characters! > it has to be a local file (I haven't tested network / UNC paths) > > file extensions: html, htm and txt > > --- Pictures ---------- > If you want to insert an image instead, use the platform agnostic (html) way of > defining the path as I am using a simple text replacement at the moment: > > html = "<img src='file:///" + path + "'\\>"; > > file extensions: png, apng, jpg, jpeg, jp2k, gif, tif, bmp, dib, rle, ico, svg, > webp > Using the %file(local path)% it gives me the error "undefined" on the message text, both for .txt or .html
(In reply to comment #23) > (In reply to comment #21) > > Using the %file(local path)% it gives me the error "undefined" on the message > text, both for .txt or .html > Please enable ST4 debug mode and take a look at tools..error console. ALso, what path are you using, and which OS are you on?
(In reply to comment #24) > (In reply to comment #23) > > (In reply to comment #21) > > > > Using the %file(local path)% it gives me the error "undefined" on the message > > text, both for .txt or .html > > > Please enable ST4 debug mode and take a look at tools..error console. ALso, > what path are you using, and which OS are you on? > Remember to follow our instructions at our troubleshooting page: http://smarttemplate4.mozdev.org/support.html use console2, set it up to show all but "content" and maybe "css" errors. (Needs at least Errors, Warning, Messages, Chrome enabled) then copy the error log using the error console right click menu. My guess is that there is a problem with the path you were passing in between the (...)
(In reply to comment #25) > (In reply to comment #24) > > (In reply to comment #23) > > > (In reply to comment #21) > > > > > > Using the %file(local path)% it gives me the error "undefined" on the message > > > text, both for .txt or .html > > > > > Please enable ST4 debug mode and take a look at tools..error console. ALso, > > what path are you using, and which OS are you on? > > > > Remember to follow our instructions at our troubleshooting page: > http://smarttemplate4.mozdev.org/support.html > > use console2, set it up to show all but "content" and maybe "css" errors. > (Needs at least Errors, Warning, Messages, Chrome enabled) > > then copy the error log using the error console right click menu. My guess is > that there is a problem with the path you were passing in between the (...) > Hi, The log is: Erro: TypeError: imgs is undefined Arquivo fonte: chrome://communicator/content/contentAreaClick.js Linha: 62 ---------- Erro: TypeError: imgs is undefined Arquivo fonte: chrome://communicator/content/contentAreaClick.js Linha: 62 ---------- SmartTemplate4 [logTime init] cleanupUnusedPrefs () ---------- SmartTemplate4 17:4:23.648 [146847 ms] SmartTemplate4.notifyComposeBodyReady() ---------- SmartTemplate4 17:4:23.650 [2 ms] insertFileLink (D:\SRV\80.Informática\0System_Files\Thunderbird\assinaturas\joaosilva-new.txt) ---------- SmartTemplate4 17:4:23.651 [1 ms] insertFile - type detected: txt ---------- SmartTemplate4 17:4:23.651 [0 ms] localFile.initWithPath( D:\SRV\80.Informática\0System_Files\Thunderbird\assinaturas\joaosilva-new.txt) ---------- Aviso: insertFileLink() Component returned failure code: 0x8050000e (NS_ERROR_ILLEGAL_INPUT) [nsIConverterInputStream.readString] The signature file is: %cursor% <br> <br> <p style="font-size:14px"><font face="Century Gothic"> <font color="#000000">Com os melhores cumprimentos | Best regards</font><br> <div style="line-height:16px; margin:6px 0; padding:8px 8px 8px 8px; border-top:1px #aeb1a6 dotted; border-bottom:1px #aeb1a6 dotted; font-family: 'Lucida Sans', Lucida Grande, Verdana, Arial, Sans-Serif; font-size:11px; color:#555555;"> <div style="display: inline-block;"><img src="file:///D:/Shares/0System_Comuns/Thunderbird/amb_logo.png" style="float:left; padding:15px 12px 15px 0;"></div> <div style="display: inline-block;"><font face="Century Gothic"><strong style="color:#333333; font-size:14px;">João Silva</strong><br>Dpto. Engenharia e Desenvolvimento <b>|</b> <i>xxxxxxxxxxxxxxxxx</i><br>xxxxxxxxxxxxxxxxxxxxxxxxxxxx</a><br> telefone: <a href="callto:+351 xxx xxx xxx" style="color:rgb(0, 136, 204) !important; text-decoration:none !important;">+351 xxx xxx xxx</a> | fax: <a href="fax:+351 xxx xxx xxx" style="color:rgb(0, 136, 204) !important; text-decoration:none !important;">+351 xxx xxx xxx</a><br> email: <a href="mailto:joaosilva@xxxxxxxxxx.com" style="color:rgb(0, 136, 204) !important; text-decoration:none !important;">JoaoSilva@xxxxxxxxx.com</a> | web: <a href="http://www.xxxxxxxx.com" style="color:rgb(0, 136, 204) !important; text-decoration:none !important;">www.xxxxxxxxx.com</a><br> </font></div></div> <font size="1px"><a href="http://www.xxxxxxxxx.com/email.jpg" style="color:rgb(137, 20, 20) !important; text-decoration:none !important;"size="2px" title="Aviso Legal / Disclaimer xxxxxxxxx"><u>Aviso Legal / Disclaimer</u></a></font><br> <div style="line-height:19px; margin:2px 0; padding:4px 4px 4px 4px;"> <img src="file:///D:/Shares/0System_Comuns/Thunderbird/ambiente.png" style="float:left; padding:0px 0px 0px 0;" width="40" height="45"><br> <font color="#009900" size="1.5px" style="line-height:10px">Antes de imprimir, pense na sua responsabilidade e compromisso para com o ambiente!<br>Before you print it think about your responsibility and commitment to the environment!</font> </font></div> <br> <img alt="" src="file:///D:/Shares/0System_Comuns/Thunderbird/info_amb.png"> <br>
The OS is Windows Server 2012 R2
Can you try an link to an ASCII(In reply to comment #26) > (In reply to comment #25) > > (In reply to comment #24) > > > (In reply to comment #23) > > > > Remember to follow our instructions at our troubleshooting page: > > http://smarttemplate4.mozdev.org/support.html > > > > use console2, set it up to show all but "content" and maybe "css" errors. > > (Needs at least Errors, Warning, Messages, Chrome enabled) > > > > then copy the error log using the error console right click menu. My guess is > > that there is a problem with the path you were passing in between the (...) > > > > Hi, > > The log is: > > ---------- > SmartTemplate4 17:4:23.650 [2 ms] > insertFileLink > (D:\SRV\80.Informática\0System_Files\Thunderbird\assinaturas\joaosilva-new.txt) please try a path that contains only ASCII characters. "Informática" will likely not work because it contains an non-ASCII "á". In the meantime, I will upload a version the uses the newer "FileUtil" object.
Created an attachment (id=8043) [details] 0.9.7 prerelease 111 Using FileUtil instead. I was able to insert the text from your signature as you suggested. Note that this version currently does _not_ support using variables _within_ the file.
Created an attachment (id=8044) [details] 0.9.7 prerelease 113 This version includes expansion of other variables within the html file. Make sure to use the file extension htm or html.
(In reply to comment #30) > Created an attachment (id=8044) [details] [details] > 0.9.7 prerelease 113 > > This version includes expansion of other variables within the html file. Make > sure to use the file extension htm or html. > Hi, I have done what you said about the path but is still gives me this error: SmartTemplate4 9:19:9.446 [0 ms] insertFile - type detected: html ---------- SmartTemplate4 9:19:9.446 [0 ms] localFile.initWithPath( D:\SRV\09.Comuns\joaosilva-new.html) ---------- Aviso: insertFileLink() Component returned failure code: 0x8050000e (NS_ERROR_ILLEGAL_INPUT) [nsIConverterInputStream.readString] On the email it shows also: Component returned failure code: 0x8050000e (NS_ERROR_ILLEGAL_INPUT) [nsIConverterInputStream.readString]
(In reply to comment #31) > (In reply to comment #30) > > Created an attachment (id=8044) [details] [details] [details] > > 0.9.7 prerelease 113 > > > > This version includes expansion of other variables within the html file. Make > > sure to use the file extension htm or html. > > > > Hi, > > I have done what you said about the path but is still gives me this error: > > SmartTemplate4 9:19:9.446 [0 ms] > insertFile - type detected: html > ---------- > SmartTemplate4 9:19:9.446 [0 ms] > localFile.initWithPath( D:\SRV\09.Comuns\joaosilva-new.html) > ---------- > Aviso: insertFileLink() > Component returned failure code: 0x8050000e (NS_ERROR_ILLEGAL_INPUT) > [nsIConverterInputStream.readString] > > On the email it shows also: > Component returned failure code: 0x8050000e (NS_ERROR_ILLEGAL_INPUT) > [nsIConverterInputStream.readString] > I found this, which points to the fact that this is an encoding issue: http://stackoverflow.com/questions/13564592/ns-error-illegal-input-error-while-trying-to-read-local-txt-file-using-xul can you encode the file with UTF-8 instead? The easiest way on windows is by using notepad++ and then choosing Encoding/"Encode in UTF-8 without BOM"(*). I believe I sent you a html file with your signature via mail, did you receive this or do you want me to append it to this bug? (*) If you are using notepad (not notepad++) there is an option on the Save as dialog at the bottom right "Encoding: " - select UTF-8. This is the standard which will work with all Latin and Eastern European Languages.
Created an attachment (id=8045) [details] 0.9.7 prerelease 115 Here is a new version with an added optional "charset" parameter. usage: %file(fileName)% %file(fileName,charset)% (no spaces allowed!) if charset is omitted, ST4 will assume UTF-8 as character set. If you are using a Windows (ANSI) encoded file try "Windows-1252" Example: %file(E:\Dev\Mozilla\DEV\SmartTemplate\Test\file\testFileANSI.html,Windows-1252)% works for me after I encoded your signature as ANSI (windows notepad standard) You may also try: ISO-8859-1 both worked for me after re-encoding the HTML as ANSI. UTF-8 is the best one though as it supports the most languages.
(In reply to comment #33) > Created an attachment (id=8045) [details] [details] > 0.9.7 prerelease 115 > > Here is a new version with an added optional "charset" parameter. > usage: > %file(fileName)% > %file(fileName,charset)% (no spaces allowed!) > > if charset is omitted, ST4 will assume UTF-8 as character set. > > If you are using a Windows (ANSI) encoded file try "Windows-1252" > > Example: > > %file(E:\Dev\Mozilla\DEV\SmartTemplate\Test\file\testFileANSI.html,Windows-1252)% > > works for me after I encoded your signature as ANSI (windows notepad standard) > > You may also try: ISO-8859-1 > both worked for me after re-encoding the HTML as ANSI. > > UTF-8 is the best one though as it supports the most languages. > I have used UTF-8, and its working great! Now even works on a path with non-ASCII "D:\SRV\80.Informática". Your app is getting more awesome every time. Now the only problem is the assyncronous mode, but that is another story. About the signature programing i have used your changes that you have done on the html, with some adjust and is working great also. You are top!
Created an attachment (id=8046) [details] 0.9.7 prerelease 126 Added support for inserting a "%file%" variable into the template. Note: Only the German and English locale are currently in this, I need to make a trip to babelzilla.org to get the defaults for the other languages. Do not test in Tb of any other language.
Created an attachment (id=8047) [details] 0.9.7 prerelease 129 Same as previous version (includes %file()% interface) but with missing strings replaced (English). So this one works in all languages again. Descriptions will be in English until translators have provided localized versions.
Created an attachment (id=8048) [details] 0.9.7 prerelease 131 Turns out there was a problem with replacing \ with / for the file link in Windows (Image worked though). This version addresses this problem and is now also compatible and tested with Postbox and SeaMonkey.
Hi, Is the option: %file(imagePath,altText)% Working? I have try and i only get a broken link, not the alternative text.
(In reply to comment #38) > Hi, > > Is the option: > %file(imagePath,altText)% > Working? > > I have try and i only get a broken link, not the alternative text. > Yes it is working for me. You cannot see the alt text in composer, but if you save the email and look in drafts / preview it shows. the alt text may not contain the following characters: ( ) ,
(In reply to comment #39) > (In reply to comment #38) > > Hi, > > > > Is the option: > > %file(imagePath,altText)% > > Working? > > > > I have try and i only get a broken link, not the alternative text. > > > > Yes it is working for me. You cannot see the alt text in composer, but if you > save the email and look in drafts / preview it shows. > > the alt text may not contain the following characters: ( ) , > Ok. In the editor while writing the email if the image dont show it apears the broken link image, and only after send the email it changes for the alternative text. And i havent send it to try. Thanks
(In reply to comment #40) > (In reply to comment #39) > > (In reply to comment #38) > > > Hi, > > > > > > Is the option: > > > %file(imagePath,altText)% > > > Working? > > > > > > I have try and i only get a broken link, not the alternative text. > > > > > > > Yes it is working for me. You cannot see the alt text in composer, but if you > > save the email and look in drafts / preview it shows. > > > > the alt text may not contain the following characters: ( ) , > > > > Ok. > In the editor while writing the email if the image dont show it apears the > broken link image, and only after send the email it changes for the alternative > text. > And i havent send it to try. yes or you save, navigate to the "drafts" folder and look at the last saved version (preview). As soon as you Edit the mail you will see the "beoken image" placeholder instead.
*** Bug 25058 has been marked as a duplicate of this bug. ***