MozillaZine

Autoopening of attachments!

Discussion of features in Mozilla Thunderbird
Qwar
New Member
 
Posts: 1
Joined: October 15th, 2017, 2:03 am

Post Posted October 15th, 2017, 2:08 am

Hi,

I have a remote camera that mail me a *.jpg file if anything moves in front of it. I want to configure thunderbirs in the way that it automatically loads the jpg-file and shows me the pic if I select the mail that it's within. Now I have to doubleclick on the attachment..

Thanks

DanRaisch
Moderator

User avatar
 
Posts: 117720
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Post Posted October 15th, 2017, 5:26 am

Have you tried setting Thunderbird to display attachments inline? Menu path View->Display Attachments Inline.

tanstaafl
Moderator

User avatar
 
Posts: 43264
Joined: July 30th, 2003, 5:06 pm

Post Posted October 16th, 2017, 1:44 am

That will work but it is a security risk since it will automatically open any attachment, including spam. You might be able to use a message filter to automatically open and display any attachments using a "open file" action after testing that the message was sent from a specific email address (your remote camera). The FiltaQuilla add-on adds a "open file" action and a javascript action to message filters, among other things.

https://addons.mozilla.org/en-US/thunde ... la/?src=ss

morat
 
Posts: 2444
Joined: February 3rd, 2009, 6:29 pm

Post Posted October 16th, 2017, 7:17 am

The FiltaQuilla Javascript Action stuff is pretty difficult.

Here is an old example of autoprinting the first attachment with LibreOffice. (not tested with current release)

Code: Select all
/*Javascript Action*/
function urlListener(aPath) {
  this.OnStartRunningUrl = function(aUrl) {}
  this.OnStopRunningUrl = function(aUrl, aExitCode) {
    if (Components.isSuccessCode(aExitCode)) {
      var localFile = Components.classes["@mozilla.org/file/local;1"].
        createInstance(Components.interfaces.nsILocalFile);
      var process = Components.classes["@mozilla.org/process/util;1"].
        createInstance(Components.interfaces.nsIProcess);
      var args = ["-norestore", "-nofirststartwizard", "-nologo",
        "-headless", "-p", aPath];
      localFile.initWithPath("C:\\Program Files\\LibreOffice 3.5" +
        "\\program\\soffice.exe");
      process.init(localFile);
      process.run(false, args, args.length);
    }
  }
}
for (var i = 0; i < msgHdrs.length; i++) {
  var msgHdr = msgHdrs.queryElementAt(i, Components.interfaces.nsIMsgDBHdr);
  MsgHdrToMimeMessage(msgHdr, null, function(aMsgHdr, aMimeMsg) {
    if (aMimeMsg == null) return; // shouldn't happen, but sometimes does?
    var msgURI = aMsgHdr.folder.generateMessageURI(aMsgHdr.messageKey);
    var attachment = aMimeMsg.allAttachments[0];
    var file = Components.classes["@mozilla.org/file/directory_service;1"].
      getService(Components.interfaces.nsIProperties).
      get("TmpD", Components.interfaces.nsIFile); // temporary folder
    file.append(attachment.name);
    file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE,
      parseInt("666", 8));
    // 0666 read and write permission for owner, group, others
    // example.txt example-1.txt example-2.txt example-3.txt et cetera
    var messenger = Components.classes["@mozilla.org/messenger;1"].
      createInstance(Components.interfaces.nsIMessenger);
    messenger.saveAttachmentToFile(file, attachment.url, msgURI,
      attachment.contentType, new urlListener(file.path));
  }, false /*allowDownload*/);
}

Reference
https://dxr.mozilla.org/comm-release/se ... imeMessage
https://dxr.mozilla.org/comm-release/so ... mimemsg.js
https://dxr.mozilla.org/comm-release/so ... senger.idl

Starting the LibreOffice Software With Parameters
http://help.libreoffice.org/Common/Star ... Parameters

Return to Thunderbird Features


Who is online

Users browsing this forum: No registered users and 0 guests