Drafts Action Directory

Send a Website

Posted by @HobbieJacob, Last update about 1 month ago

Send your website quickly and save a person’s contact information and name quickly! Great for networking events.

Instructions

Setup

  • Find all “NOTE:” instances in the comments
  • Replace all necessary information, (at minimum, name and URL)
  • Customize the Text and Email text in order to make it more personal

Use

  • Type the name of your contact in the first line, or the “title”
  • Type either an email address or a phone number in the next line of the draft
  • Tap the action! The draft will be archived afterwards and saved with the tag “career”

More

If you want to know when I update this action, either follow me on Twitter, @HobbieJacob, or check out my website, https://jacobhobbie.com. Enjoy!

Install

Steps

  • script

    // Send Website - Drafts Directory
    // Made by Jacob Hobbie
    
    // INSTRUCTIONS:
    // "NOTE:" Notifies you of anything you need to change manually.
    // Feel free to change any strings in the script in order to match your own voice. One of the most important aspects in networking is being yourslef!
    
    // Setting Regular Expressions
    const REGEX_PHONE = /^(\+\d{1,2}\s)?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/;
    const REGEX_EMAIL = /^\S+@\S+$/;
    // Other Variables
    // NOTE: Insert your name here:
    const NAME = "[Name]";
    const SUB = NAME + "'s Website";
    // NOTE: Enter your URL here:
    const SITE = "[URL]";
    
    // Get First Line
    var name = draft.processTemplate("[[title]]");
    
    // Get Second Line
    var contact = draft.processTemplate("[[body]]");
    
    // Check Draft Content
    if (REGEX_PHONE.test(contact)) {
      // Send Text
      var msg = Message.create();
      msg.toRecipients = [contact];
      msg.subject = SUB;
      msg.body = SUB + ": " + SITE;
      var pass = msg.send();
    
       // Error Check
      if (pass) {
        console.log("Text Successfully Sent!");
      } else {
        context.fail("Text not sent either by user intervention or error.");
      }
    } else if (REGEX_EMAIL.test(contact)) {
      // Send Email
      var mail = Mail.create();
      mail.toRecipients = [contact];
      mail.subject = SUB;
      mail.body = "Hello,\n\nI wanted to send you my website in case you wanted to see my past work, and some of my writing as well. Enjoy!\n\n" + SITE;
      mail.send();
    
      // Error Check
      if (mail.status == "sent") {
        console.log("Email Successfully Sent!");
      } else if (mail.status == "savedAsDraft" || "userCancelled") {
        context.fail("Email cancelled by user or saved as draft.");
      } else {
        context.fail("Error occured while sending email.");
      }
    } else {
      context.fail("Contact couldn't be parsed. Either regular expression or contact info is bad.");
    }

Options

  • After Success Archive
    Notification Info
    Log Level Info

Comments

Actions available in the Action Directory are uploaded by community members. Use appropriate caution reviewing downloaded actions before use.