Bugzilla@Mozdev – Bug 26552
Variable for attaching [pdf] files
Last modified: 2019-07-28 07:15:31
You need to log in before you can comment on or make changes to this bug.
Would like to be able to create templates with pdf's attached...like the add-on QuickText can do.
For starters , I guess you want to add the absolute, fixed path to the file [similar to the %file(...)% function]. But I can imagine you might also have a more demanding use case, such as if a user requests a particular document (name) e.g. via a web request form, it might be good to have additional functionality (regex matching) extracting the pdf name from the replied email... Let's leave that for stage 2 but I am definitely interested in your current use case. Can you elaborate a bit more why you would attach the same pdf file to different people?
(In reply to comment #1) > For starters , I guess you want to add the absolute, fixed path to the file > [similar to the %file(...)% function]. > > But I can imagine you might also have a more demanding use case, such as if a > user requests a particular document (name) e.g. via a web request form, it > might be good to have additional functionality (regex matching) extracting the > pdf name from the replied email... Let's leave that for stage 2 but I am > definitely interested in your current use case. > > Can you elaborate a bit more why you would attach the same pdf file to > different people? > Each time someone signs up for a specific course they will be sent a standard email with relevant attachments.
Working on it right now - turns out a lot more difficult than I expected. This needs to be programmed asynchronously using Task.jsm and OS.File, the file needs to be checked for existence and queried for filename; content type may also need to be determined. IIn Composer, there is a built in function window.AddAttachments but it expects and array of nsIMsgAttachment entities, and to make up these we need to do all the heavy lifting of finding the file and what kind of content; this stuff needs to be done asynchronously so it is much harder than just plugging in a location on a hard drive... expect this implementation to take a while. Relevant snippets from Thunderbird code base ============================================ https://dxr.mozilla.org/comm-central/source/mail/components/compose/content/MsgComposeCommands.js#2721 https://dxr.mozilla.org/comm-central/source/mailnews/compose/test/unit/head_compose.js#115 File handling from drag&drop: https://dxr.mozilla.org/comm-central/source/mail/components/compose/content/MsgComposeCommands.js#2508
Created an attachment (id=8489) [details] 1.6 prerelease 73 My previous comment was sitting in the browser unsubmitted for one or 2 hours while I was coding away. Turns out I do not need async for this. Attached is a first test version. While I was testing (with a txt file no less) I also found that the %file()% function does not expand new line characters of text into the much needed <br> so I fixed this as well quickly.
Syntax (at the moment): %attach(filePath)% Example: %attach(D:\Music\John\Long Story\lyrics.txt)% Notes: I am using nsIMIMEService for determining the file type, not sure how it will react to different types of files. To do: add this to the variable window so the filePath can be more eeasily added by clicking on the %attach% example there (like %file%).
Hi, I just tested 1.6pre73 adding 2 pdf's and it worked. Well done and thanks.
(In reply to comment #5) > %attach(D:\Music\John\Long Story\lyrics.txt)% Does this work for GNU+Linux computers?
(In reply to comment #7) > (In reply to comment #5) > > %attach(D:\Music\John\Long Story\lyrics.txt)% > Does this work for GNU+Linux computers? > It should work, I am retrieving the path from a file picker when you click the %attach% variable on the right hand side of ST⁴ options (variables tab), so obviously the URL will look different. Note: The variables tab sure could use a search function.
Created an attachment (id=8491) [details] 1.6 prerelease 75 Added the file picker mechanism. Note this test version only has English and German locales complete. If you need your local language please contribute the string: <!ENTITY attach.label "Add file as attachment"> for smartTemplate-settings.dtd on this bug, or here: http://adofex.clear.com.ua/projects/p/smarttemplate4/ We can use contributions for the locales: French Italian Japanese Portuguese (Brazil) Russian Slovenian Spanish (Spain) Ukrainian Polish Serbian Finnish Chinese (China) Dutch Czech Swedish (Sweden) Occitan (post 1500) Chinese (Taiwan) Turkish
Resolved Fixed: Version 2.0 - 23/12/2018