Bugzilla@Mozdev – Bug 26552
Variable for attaching [pdf] files
Last modified: 2019-07-28 07:15:31
You need to
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
(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
File handling from drag&drop:
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):
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
<!ENTITY attach.label "Add file as attachment">
on this bug, or here:
We can use contributions for the locales:
Occitan (post 1500)
Resolved Fixed: Version 2.0 - 23/12/2018