8000 Feature request: Set a default template to be automatically applied on a new/replied/forwarded email · Issue #200 · jobisoft/quicktext · GitHub
[go: up one dir, main page]

Skip to content

Feature request: Set a default template to be automatically applied on a new/replied/forwarded email #200

Open

Description

@atsiakas

It would be great if a template could be automatically applied when creating a new email or when replying/forwarding an existing email.

Activity

  1. SamuelPlentz commented on Nov 4, 2020

    @SamuelPlentz
    Contributor

    Duplicate of #163. The name of the issue is better here though.
    We should close the other one.

  2. xpseudonym commented on Feb 2, 2021

    @xpseudonym

    My apologies for a 'me too' post - but, I'd also like to thank John for his work porting this and Emil before him - do you drink coffee; can I buy you one :)
    So, yes, a default would save one more repetitive mouse click.

  3. reagle commented on Feb 12, 2021

    @reagle

    Yes! Just landed here to see how this was done so I don't have to keep manually invoking my Hi [[TO=firstname]],\n\n macro.

  4. SamuelPlentz commented on Feb 13, 2021

    @SamuelPlentz
    Contributor

    I am not sure how it could be implemented especially on a new email. The question is when the template should be applied.

    1. If it would be applied directly on start of a new email a variable like [[TO=firstname]] is useless, as one didn't add the recipients yet. This is similar when forwarding an email. A reply would usually be fine with it.

    2. If it would be applied when adding the first recipient one could already have written parts of the email and it might be an unwanted 8000 action to add the template at this point.

    On the other way a script like CleanSubject would work fine with (1) also when forwarding.

    How would you think it should work? Would you use it just for replies with (1) or do you see any other use cases for new and forwarded emails, that I am missing?

  5. reagle commented on Feb 13, 2021

    @reagle

    Good points, a couple options:

    1. It could continue to use the same behavior it has now. That is, if I invoke my greeting macro on a new email the result is simply "Hi,".
    2. Can you test if it's a reply, forward, or new?
    3. If a variable doesn't exist within a macro, don't emit anything.

    BTW: I appreciate that this request is pushing quicktext to expand from a macro expander to an email template system, which could be out of scope. In the past, I paid for SmartTemplates just for the ability to have an automatic greeting. But when they moved to an annual fee, I thought that was too much just to say "Hi [[name]]".

  6. daelrum commented on May 5, 2021

    @daelrum
    Contributor

    Hello all,

    after a bit of work i have manage to somehow solve the problem (not autoaplied but almost with keyword) of this treath by using 3 adapted community scripts (also adding different signatures depending if its new mail or Re:/Fwd:)

    you can also aply it after writting the email just making sure to select written text and greeting will be placed at start and signature at end (above the Re:/Fwd: message text)

    the scripts used are:
    1.-CleanSubject (used as it is and added following scripts depending if ""/"Re: "/"Fwd: " is the starting subject to edit greeting and signature imputed from templeate)
    2.-GoodMorning (modified hours and added ToNickname into greeting string)
    3.-ToNickname (modified so that if neither nickname nor firstname is present "" is returned an only greeting is written)
    4.- GetMailBody (unmodified)

    -so if new mail will be shown like:

    
    Good (morning/evening...) ToNickname,
     | (cursor will be here)
    full signature (html)
    
    

    -Re: mail will be like:

    Good (morning/evening...) ToNickname,
     | (cursor will be here)
    small signature (html)
    
    

    -Fwd: mail will be like:

    FYI
     | (cursor will be here)
    small signature (html) 
    

    my full composition will be like:

    templates inside "saludos" folder:

    • name mail : this will add full scripted template (input type HTML)

    [[SCRIPT=filtrado]]

    • name firm : this will add full html signature (input type HTML)


    [[CURSOR]][[FILE=C:\firm.html]]

    • name respose : this will add short html signature (input type HTML)


    [[CURSOR]][[FILE=C:\response.html]]

    Scripts:

    • name greeting (edited GoodMorning Script)
    var date = new Date();
    if (date.getHours() <12) return "Good morning "+"[[SCRIPT=to]]"+",<br><br>";
    if (date.getHours() < 20) return "Good afternoon "+"[[SCRIPT=to]]"+",<br><br>";
    if (date.getHours() > 20) return "Good night "+"[[SCRIPT=to]]"+",<br><br>";
    return "Hello"+[[SCRIPT=to]]+",<br><br>"; 
    

    -name to (edited ToNickname) added blond text

    var data = this.mQuicktext.process_to(mVariables);
    
    // use name if nickname is not available
    if(typeof data['nickname'] == 'undefined') {
      data['nickname'] = [];
    }
    for(var i = 0; i < data['firstname'].length; i++) {
      if(typeof data['nickname'][i] == 'undefined') {
    **if(typeof data['firstname'][i] == 'undefined') {
        data['firstname'][i] = " ";
      }**
        data['nickname'][i] = data['firstname'][i];
      }
    }
    
    if(typeof data['nickname'] != 'undefined') {
      if(mVariables.length < 1) mVariables[0] = ", ";
      return data['nickname'].join(mVariables[0].replace(/\\n/g, "\n").replace(/\\t/g, "\t"));
    } else return "";
    

    main script named filtrado

    // get subject from email if possible
    if(!this.mWindow.document.getElementById('msgSubject')) return "";
    let subject = this.mWindow.document.getElementById('msgSubject').value;
    
    
    // detect first prefix
    
    let firstPrefix = "";
    firstPrefix="";
    if(subject.toLowerCase().startsWith("re: "))  firstPrefix = "Re: ";
    if(subject.toLowerCase().startsWith("fwd: ")) firstPrefix = "Fwd: ";
    
    
    // search and remove all prefixes
    let previousLength = 0;
    while(previousLength != subject.length) { // repeat the process if something gets shortened
      previousLength = subject.length;
    
      subject = subject.replace(/^(re:\s|r:\s|aw:\s|antw:\s|antwort:\s)/i, "");    // replace "Re: ", "R: ", "Aw: ", "Antw: ", "Antwort: "
      subject = subject.replace(/^(fwd:\s|fw:\s|wg:\s|wt:\s|wtrlt:\s)/i, "");      // replace "Fwd: ", "Fw: ", "Wg: ", "Wt: ", "Wtrlt: "
      subject = subject.replace(/^(Re-\d:\s|Re\[\d\]:\s)/i, "");                   // replace "Re-1: ", "Re-2: ", "Re[1]: ", "Re[2]: "
      subject = subject.replace(/^(\*\*\*\*SPAM\*\*\*\*\s|\[SPAM\]\s)/i, "");      // replace "****Spam**** ", "[Spam] "
      subject = subject.replace(/^(Automatische Antwort:\s)/i, "");                // replace "Automatische Antwort: "
      subject = subject.replace(/^(\[Extern]\s-\s|\[Extern]\s|\[Extern]:\s)/i,""); // replace "[Extern] - ", "[Extern] ", "[Extern]: "
      subject = subject.replace(/^(\[Probable Suspicious URLs\]\s)/i,"");          // replace "[Probable Suspicious URLs] "
      subject = subject.trim();
    }
    
    
    // reuse first prefix and change subject
    subject = firstPrefix + subject;
    this.mWindow.document.getElementById('msgSubject').value = subject;
    
    
    switch(firstPrefix){
    case "":
    return this.mQuicktext.get_script(["greeting"])+this.mQuicktext.get_script(["GetMailBody"])+ "[[TEXT=saludos|firm]]"
    break;
    case "Re: ":
    return this.mQuicktext.get_script(["greeting"])+this.mQuicktext.get_script(["GetMailBody"])+"[[TEXT=saludos|response]]"
    break;
    case "Fwd: ":
    return "FYI"+
    "[[TEXT=saludos|response]]";
    
    }
    
    
    
  7. jobisoft commented on Jun 3, 2021

    @jobisoft
    Owner

    The new WebExtension APIs will make that easy, postponing.

  8. changed the title [-]Feature Request: Set a default template to be automatically applied on a new/replied/forwarded email[/-] [+]Feature request: Set a default template to be automatically applied on a new/replied/forwarded email[/+] on Jun 3, 2021
  9. Francewhoa commented on Dec 14, 2021

    @Francewhoa

    I am also interested in this new feature. If needed, I would be happy to contribute testing and documentation.

  10. Francewhoa commented on Dec 14, 2021

    @Francewhoa

    How about

    I am not sure how it could be implemented especially on a new email. The question is when the template should be applied.

    How about per this below? Shorted top down during the initial one time configuration top-down:

    1. Per email account. And per identity.
      First, implement this new feature per email account. And optionally, per identity.
    2. On new email, reply, forward
      Then, optionally, choose one script on write new email or on reply or on per forward
    3. Activate or deactivate
      Next, optionally, activate the script or not, on write new email or on reply or on per forward
    4. Quicktext somehow easily find the reusable script
      After that, somehow store the script into an appropriate location. So that in the future, quicktext can find it when it's automatically triggered

    This screenshot shows this suggestion


    Maybe some of this could be recycled as inspiration for the logic? Or maybe some code too? As, it's from SmartTemplate4. Which is also Libre/Open Source.

  11. myde2001 commented on Aug 15, 2023

    @myde2001

    Hi, still nothing new on this topic? It would be great to have. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0