A Toolbar Button to Compose a Message in Gmail

Following to discussion in Button to create Google Calendar event based on the current tiddler - Tips & Tricks - Talk TW (tiddlywiki.org)

I have developed a script to compose an email in Gmail using the currentTiddler data.

caption: {{$:/plugins/kookma/tweaks/images/gmail}} {{$:/language/Buttons/Gmail/Caption}}
description: {{$:/language/Buttons/Gmail/Hint}}
tags: $:/tags/ViewToolbar
title: $:/plugins/kookma/tweaks/ui/Buttons/compose-gmail

with below contnet

\whitespace trim
\procedure baseGmailUri() https://mail.google.com/mail/
\procedure viewMode()     view=cm&fs=1
\procedure gmailLinkTemplate() $(baseGmailUri)$?$(viewMode)$&to=$(get.recipients)$&cc=$(get.cc)$&bcc=$(get.bcc)$&su=$(get.subject)$&body=$(get.body)$

\function get.recipients() [all[current]get[recipients]]
\function get.cc()         [all[current]get[cc-recipients]]
\function get.bcc()        [all[current]get[bcc-recipients]]

\function get.subject()    [all[current]get[title]]
\function get.body()       [<wikifiedText>encodeuricomponent[]]

\function get.gmail.link() [<gmailLinkTemplate>substitute[]]

\procedure sendGmailActions()
<$action-listops $tiddler=<<currentTiddler>> $tags="[[Gmail]]"/>
<$wikify name="wikifiedText" text={{!!text}} output="formattedtext">
	<$action-sendmessage $message="tm-open-external-window" $param=<<get.gmail.link>> />
</$wikify>
\end


<$button tooltip={{$:/language/Buttons/Gmail/Hint}} aria-label={{$:/language/Buttons/GoogleCalendar/Caption}} class=<<tv-config-toolbar-class>> actions=<<sendGmailActions>> >
	<%if [<tv-config-toolbar-icons>match[yes]] %>
		{{$:/plugins/kookma/tweaks/images/gmail}}
	<%endif%>
	<%if [<tv-config-toolbar-text>match[yes]] %>
		<span class="tc-btn-text">
			<$text text={{$:/language/Buttons/Gmail/Caption}}/>
		</span>
	<%endif%>
</$button>
  • It only passes the tiddler text as formattedtext not rich text
  • Credits go to @saqimtiaz and @vilc

Please share your solution, improvement here.

2 Likes

A demo can be found here Tweaks Plugin — kookma fixes and customization for TiddlyWiki

Nice! Works well with compact tiddlers.

How about also opening this up to other email providers? It works with Fastmail using the following link pattern:

\procedure baseFastmailUri() https://app.fastmail.com/mail/Inbox/compose/
\procedure fastmailLinkTemplate() $(baseFastmailUri)$?$&to=$(get.recipients)$&cc=$(get.cc)$&bcc=$(get.bcc)$&subject=$(get.subject)$&body=$(get.body)$

(As in https://app.fastmail.com/mail/Inbox/compose?to=jane.doe@example.com&bcc=john.doe@example.com&subject=Meeting%20Tomorrow&body=Hi%20there,%0D%0ALooking%20forward%20to%20our%20meeting%20tomorrow.%0D%0ABest,%0DJohn).

2 Likes

You did it! For other emails or a default email client, the URL should be corrected.
See the pioneer work by Ibnishak: https://ibnishak.github.io/Tesseract/pluginsandmacros/socialmacros/index.html

1 Like