Action

Email Teacher…

Posted by @nahumck, Last update over 5 years ago

Email one of your child’s teachers based on subject name. Note: change variables in the first script step to customize for your child, as well as the email step for your child’s name and your signature.

Steps

  • script

    // Email Teachers Script - Variables
    
    var subjects = ["English", "Algebra", "CompSci", "Government", "Physics", "Spanish", "Test"];
    
    var subjectName = {
      'English':'AP English',
      'Algebra':'Algebra II',
      'CompSci':'AP Computer Science Principles',
      'Government':'AP Government',
      'Physics':'Physics',
      'Spanish':'Spanish I',
      'Test':'Test Class',
    };
    
    var emailList = {
      'English':'name@email.com',
      'Algebra':'name@email.com',
      'CompSci':'name@email.com',
      'Government':'name@email.com',
      'Physics':'name@email.com',
      'Spanish':'name@email.com',
      'Test':'test@nahumck.me',
    };
    
    var teacherList = {
      'English':'Mr. Name',
      'Algebra':'Mrs. Name',
      'CompSci':'Mr. Name',
      'Government':'Mrs. Name',
      'Physics':'Mr. Name',
      'Spanish':'Mrs. Name',
      'Test':'Mr. Nahumck',
      };
  • script

    // Prompt
    
    var p = Prompt.create();
    p.title = "Email Teacher";
    p.message = "Select Subject…";
    for (var subject of subjects) {
    	p.addButton(subject);
    }
    var con = p.show();
  • script

    // Set up items for email
    
    if (con) {
      var button = p.buttonPressed;
     
      // get matching items from objects
      var courseName = subjectName[button];
      var courseEmail = emailList[button];
      var courseTeacher = teacherList[button];
    
      // Create [[tags]] to use in URL step
      draft.setTemplateTag('Course',courseName);
      draft.setTemplateTag('Email',courseEmail);
      draft.setTemplateTag('Teacher',courseTeacher);
    }
    else {
      context.cancel();
    }
  • mail

    toRecipients
    [[Email]]
    ccRecipients
    bccRecipients
    subjectTemplate
    [[Course]] - Kid's Name
    bodyTemplate
    Dear [[Teacher]],

    %%[[selection]]%%
    Regards,
    Name
    phone number
    Email
    sendAsHTML
    true
    sendInBackground
    false

Options

  • After Success Default
    Notification Info
    Log Level Error
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.