Editorial Workflows

SendToKindle

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: This workflow attaches the current file to an email and sends it directly to your Kindle.

Before using you must set the following variables in the workflow:

* Your FROM email address
* Your KINDLE email address (such as <somename>@kindle.com)
* Your SMTP Server (such as smtp.gmail.com)
* Your SMTP secure Server Port (465)

The workflow prompts for your password as it it not stored in the workflow.

Note: Any files sent to the Kindle must have a suffix of: txt or html (Not md)

The attachment supports UTF8.

Shared by: daveterry

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Set your "from" email address ?
Variable Name
FromEmailAddress
Value
Set your Kindle email address ?
Variable Name
KindleEmailAddress
Value
Set your smtp Server ?
Variable Name
smtpServer
Value
smtp.gmail.com
Set smtp secure server port (SSL) ?
Variable Name
smtpPort
Value
465
UI: Masked prompt for email login password ?
User Interface
Presentation Style
  • Sheet
  • Full-Screen
  • Popover
Output
Input
Use Editor Theme
ON
If… ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Stop ?
Stop
  • This Workflow
  • Repeat Block
Show HUD Alert
OFF
Message
Stopped
…End If
If… ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
Cancel
Show Alert ?
Title
Email to Kindle Canceled
Message
Button 1
OK
Output Value
Input
Button 2
(don't show)
Output Value
Button 3
(don't show)
Output Value
Show Cancel Button
OFF
Stop ?
Stop
  • This Workflow
  • Repeat Block
Show HUD Alert
OFF
Message
Stopped
…End If
Run Python Script ?
Source Code
#coding: utf-8
# with credit to: https://docs.python.org/2/library/email-examples.html
#
import workflow
import editor
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

action_in = workflow.get_input()
pw = workflow.get_variable('pw')
KindleEmailAddress = workflow.get_variable('KindleEmailAddress')
FromEmailAddress = workflow.get_variable('FromEmailAddress')
smtpServer = workflow.get_variable('smtpServer')
smtpPort = workflow.get_variable('smtpPort')

COMMASPACE = ', '

# Create the container for email message.
msg = MIMEMultipart()
msg['Subject'] = 'Kindle'
msg['From'] = FromEmailAddress
msg['To'] = KindleEmailAddress
msg.preamble = 'Attachment'

filename = editor.get_path()
f = file(filename)
attachment = MIMEText(f.read())
attachment.add_header('Content-Disposition', 'attachment', filename=filename)
# attach the file
msg.attach(attachment)

# Send to SMTP server
smtpObj = smtplib.SMTP_SSL(smtpServer, int(smtpPort))
smtpObj.ehlo()
smtpObj.login(FromEmailAddress, pw)
smtpObj.sendmail(FromEmailAddress, KindleEmailAddress, msg.as_string())
smtpObj.quit()

#TODO: Generate the output...
action_out = action_in
workflow.set_output(action_out)