diff --git a/bundles/org.openhab.binding.mail/README.md b/bundles/org.openhab.binding.mail/README.md index 21c5ce6d8..04138cede 100644 --- a/bundles/org.openhab.binding.mail/README.md +++ b/bundles/org.openhab.binding.mail/README.md @@ -130,7 +130,7 @@ Both functions return a boolean as the result of the operation. `recipient` can be a single address (`mail@example.com`) or a list of addresses, concatenated by a comma (`mail@example.com, mail2@example.com`). -Since there is a separate rule action instance for each `smtp` thing, this needs to be retrieved through `getActions(scope, thingUID)`. +Since there is a separate rule action instance for each `smtp` thing, this needs to be retrieved through `getActions(scope, thingUID)` (DSL) or `actions.get(scope, thingUID)` (Javascript). The first parameter always has to be `mail` and the second is the full Thing UID of the SMTP server that should be used. Once this action instance is retrieved, you can invoke the action method on it. @@ -139,6 +139,10 @@ Using different character sets may produce unwanted results. Examples: +:::: tabs + +::: tab DSL + ```java val mailActions = getActions("mail","mail:smtp:samplesmtp") val success = mailActions.sendMail("mail@example.com", "Test subject", "This is the mail content.") @@ -155,7 +159,30 @@ val List attachmentUrlList = newArrayList( val mailActions = getActions("mail","mail:smtp:sampleserver") mailActions.sendHtmlMailWithAttachments("mail@example.com", "Test subject", "

Header

This is the mail content.", attachmentUrlList) ``` +::: +::: tab JavaScript + +```javascript +val mailActions = actions.get("mail","mail:smtp:samplesmtp") +val success = mailActions.sendMail("mail@example.com", "Test subject", "This is the mail content.") +success = mailActions.sendMail("mail1@example.com, mail2@example.com", "Test subject", "This is the mail content sent to multiple recipients.") + +``` + +```javascript +import java.util.List + +val List attachmentUrlList = newArrayList( + "http://some.web/site/snap.jpg¶m=value", + "file:///tmp/201601011031.jpg") +val mailActions = actions.get("mail","mail:smtp:sampleserver") +mailActions.sendHtmlMailWithAttachments("mail@example.com", "Test subject", "

Header

This is the mail content.", attachmentUrlList) +``` + +::: + +:::: ## Mail Headers The binding allows one to add custom e-mail headers to messages that it sends. @@ -163,6 +190,11 @@ For example if you want e-mails sent by this binding to be grouped into a "threa Headers can be added inside a rule by calling the `mailActions.addHeader()` method before calling the respective `mailActions.sendMail()` method. See the example below. +:::: tabs + +::: tab DSL + + ```java rule "Send Mail with a 'Reference' header; for threaded view in e-mail client" when @@ -173,5 +205,17 @@ then mailActions.sendMail("mail@example.com", "Test subject", "Test message text") end ``` +::: +::: tab JavaScript + +```javascript +val mailActions = actions.get("mail","mail:smtp:sampleserver") +mailActions.addHeader("Reference", "") +mailActions.sendMail("mail@example.com", "Test subject", "Test message text") +``` + +::: + +:::: Note: in the case of the "Reference" header, the `` has to be an ASCII string enclosed in angle brackets.