Methods

The following methods are available to you when writing your inbox app.

Global methods: Methods available globally in the script.
MethodArgumentsReturnsDescription
debug string s
  • When writing a script, this will output any string value in a window just below the script editor.
  • When running your script against an incoming email, you will be emailed a report of all debug values.
forward new email request A simple method to forward the incoming email to other recipients. Fully supports text, html, attachments, and embedded images.
get string url Http Response Simple Http get request to the specified url
get Simple Http Request Http Response “”
httpDelete string url Http Response Simple Http delete request to the specified url
(Javascript already has a delete method.)
httpDelete Simple Http Request Http Response “”
patch Http Request Http Response Http patch request to the specified url.
post Http Request Http Response Http post request to the specified url. See the post files code snippet for details on how to post files to a site.
put Http Request Http Response Http put request to the specified url.
reply string subject,
string body
A simpler version of sendMail with the to argument set to the author of the incoming email.
sendEmail new email request A robust method to send emails exactly how you would like — text, html, to/cc/bcc, attachments, and embedded images.
sendMail string to,
string subject,
string body
A simplified sendEmail method — Send a text email to the email address specified.
sendDisconnectEmail Sends an email to the end user to clear any authentication we have stored. There is only one Obindo email sent for disconnecting, and it contains a link to a form where the user can disassociate from your script (or any others).
HTTP Requests and Responses: The global HTTP methods use these objects when connecting with other sites.
Simple Http RequestHttp RequestHttp Response
{
  • url: url
  • header: obj with string key/values
  • args:key/value parameters added to the query string
}
{
  • url: url
  • header: obj with string key/values
  • body: body text OR a file object for uploads
  • args:key/value parameters to post
}
{
  • status: Http status code
  • text: body of Http response
}
Sending emails: Send emails exactly how you would like directly from script. Emails are only sent when the script is executed (not during script validation), and are always sent from your inbox's email address.
sendEmailforward
{
  • to: email list
  • cc: email list
  • bcc: email list
  • fromName: The name in the email from field
  • subject: string
  • text: string
  • html: string
  • files: array of files
}
{
  • to: email list
  • cc: email list
  • bcc: email list
  • fromName: The name in the email from field
  • subject: Update the subject sent. Defaults to incoming email's subject.
}
(no need to worry about text, html, or files — we take care of those!)
Accepted email lists:
  • "ron@blainetravel.com"
  • "Ron <ron@blainetravel.com>"
  • "Ron <ron@blainetravel.com>; sheila@blainetravel.com"
  • ["Ron <ron@blainetravel.com>","sheila@blainetravel.com"]
  • {"emailAddress": "ron@blainetravel.com","name": "Ron"} //see message object
  • [{"emailAddress": "ron@blainetravel.com","name": "Ron"},{"emailAddress": "sheila@blainetravel.com"}]

Posting files is the same as posting them as arguments on an HTTP post. can be as easy as setting the email files to the files of the incoming message:
  • sendEmail({ to: message.from; subject: "The files you sent", files: message.files })

... or you can also get creative and construct files on the fly:
  • var file= { fileName: "text.csv", contentType: 'text/csv', value: "Col 1, Col2\nVal 1,Val2" }
  • sendEmail({ to: message.from; subject: "check this out", files: [ file ] })
The oauth2 object: A collection of methods for OAuth 2 authentication. Check the OAuth 2 documentation for more details on overriding the oauth2 methods to enable the OAuth 2 workflow.
MethodArgumentsReturnsDescription
getAuthRedirectUrl string url Stub to be overwritten. Return the url of the remote site on which the user will authenticate access to your script. Possibly this also includes setting the tokens.requestToken object.
getCallbackUrl bool isFixedUrl (optional, defaults to false) string url Returns the Obindo url which will process the redirect from the remote site after the end user authorizes your script. Often must be passed to the remote site in the querystring.

If the redirect url must be set when registering for OAuth 2 on the remote site, isFixedUrl must be set to true. See the Fixed Url code snippet for more details.
onAuthResponse string querystring Stub to be overwritten. Called after the remote site redirects the end user back to Obindo after he or she authorizes access to your script. Typically, you will take the values from the querystring and use them to set the tokens.accessToken.
refreshAccessToken Called when the access token for the end user has expired and needs to be refreshed. Must reset the tokens.accessToken object.
use string appName Use another app's OAuth2 workflow so you don't have to rewrite it in your app! The only code you'll need to write is what to do with an email once the user is successfully authenticated. Note: You can only use the OAuth2 workflow of apps you have written.
The tokens object: Used for storing the request and access tokens for the end user.
The methods getId, loadFromEmailAddress, and loadFromId are necessary only if the remote site requires one url to redirect the user to after authorization. See the Fixed Url code snippet for more details.
Method/ParameterArgumentsReturnsDescription
accessToken (property) (property) An object to store all values returned when retrieving a user's access token. Typically this is initially set in oauth2.onAuthResponse and possible reset in oauth2.refreshAccessToken
getId string id Return the unique id of the end user's token for your script.
loadFromEmailAddress string emailAddress Set the tokens object based on the end user's email address.
loadFromId string id Set the tokens object based on the unique id of the user's token.
requestToken (property) (property) An object to store all values returned when retrieving a user's request token. Typically this is initially set in oauth2.getAuthRedirectUrl and used again in oauth2.onAuthResponse, though it may not always be necessary.
The settings object: Settings for the behavior of your app.
Method/ParameterArgumentsReturnsDescription
aliasOf string appName Want more than one email address to do the same thing? Write a one line app: settings.aliasOf('<originalApp>');

Note: You can only create an alias of apps you have written.
The util object: Utility methods.
MethodArgumentsReturnsDescription
getDates string array of dates Use our parsers to get the dates found in the text passed in. Time zones optimized for the email being processed. Also useful for your own text, such as util.getDates('tomorrow');
getHeaderArgsFromObject obj string Builds a set of arguments to be passed in a Http request header from a json object.(a="1", b= "2")
getObjectFromQueryArgs string qs obj Builds a json object from a string in querystring format (a=1&b=2).
getNonce long Returns a nonce (arbitrary number used once; actually just a timestamp).
getQueryArgsFromObject(o) obj string Build a string in querystring format from a json object.
getTags string s string[] From a string, return a list of tags (noise words removed).
getTimeStamp long Returns a timestamp.
jsonify(string) string obj Builds a json object from a string in json format.
stringify(o) string Builds a string in json format from a json object.
urlEncode string s string Returns a url encoded version of the string passed in.