Action

Dictate Email to Myself

Posted by agiletortoise, Last update about 4 years ago

This example action provide a way to hands dictate a passage and have it emailed to yourself. This action does not create a draft, just emails the dictation result.

The first time you run the action you will be prompted to add your email address - which will be remembered for future use.

Using the “Add to Siri” option on this action, combined with the optional timeout in dictation, allows you to create a completely hands free way to send an email to yourself.

Steps

  • script

    // Create identifier
    // To create variants of this action which use other email addresses
    // duplicate the action and change this identifier
    let credentialIdentifier = "Email to myself";
    
    // create credential to prompt for and store the email address. 
    let credential = Credential.create(credentialIdentifier, "Enter the email you wish the \"Email to myself\" action to send to below. You will only be asked the first time you run this action.");
    
    credential.addTextField("email", "Your email");
    
    // prompt to email if necessary...
    if (credential.authorize()) {
    	// setup tag to use in Mail step...
    	draft.setTemplateTag("email", credential.getValue("email"));
    }
    else {
    	context.cancel();
    }
    
    
  • script

    // dictate text
    let s = editor.dictate();
    
    // fail action if no text was dictated
    if (!s || s.length == 0) {
    	context.fail();
    }
    else {
    	draft.setTemplateTag("content", s);
    }
  • mail

    toRecipients
    [[email]]
    ccRecipients
    bccRecipients
    subjectTemplate
    Email to myself: [[time]]
    bodyTemplate
    [[content]]
    sendAsHTML
    false
    sendInBackground
    true

Options

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