Send Tiddler via eMail

Hello TW-Friends,

I read @TW_Tones Sending a tiddler or tiddlers via email? - Discussion - Talk TW (tiddlywiki.org) thread.

I know that it is not possible to attach the tiddler to a mail :wink:

I am using [ext[Send a mail|mailto:name@example.com?subject=Report&body=Hello]] very successfully.
Is it possible to replace the body with the tiddler, the same content as used as export as *.tid?

Maybe something like [ext[Send a mail|mailto:name@example.com?subject=Report&body=<<currentTiddler>>]] ?

Thank you
Stefan

Are you asking the email body to contain the text field of the named tiddler?

Hi @TW_Tones,

I will take what is possible.
Yes, my dream is to transfer the complete tiddler to the email body as:

Field One: The first field
created: 20240822101732531
creator: Author
modified: 20240822103515921
modifier: Author
tags: [[Alpha Tag]]
title: New Tiddler 1

Tiddler content.

Stefan

I did change company-com to example.com, because that one can be used for all type of URL examples. It’s reserved exactly for that purpose. It does no harm to use it.

-m

1 Like

This is possible, you need a template to present the tiddler in this form as the body and in the mail to:

Perhaps setting the body last so it can contain New lines.

It will open the default email app from which you can send.

It is theoretically possible to attach files such as tiddlers, json and binary files but they need to be added to the body after encoding and with mime type headers. Some email apps may not accept such attachments.

I have wasted many hours trying to do this but not yet succeeded :slightly_frowning_face:

Hi @TW_Jones,

@pmario realized a very good working solution to export the current tiddler here: Replace the save button with export tiddler function

I am not sure if this will solve your requirements but I will start some tests by

  1. Save the tiddler (No changes to the standard download folder settings)
  2. Open a mail in the standard mail app with the tiddler saved in (1)

Did you tested more than the standard [ext[Send attachment|mailto:name@example.com?subject=Attachment&body=Hello&?attach='Path_and_Filename' ]] ? What is not working in my environment.
I want to avoid double work and testing … :smiley:

Stefan

This is very similar to saving a .tid file, but also a bit tricky.

We can use the same template, as used to save the .tid file. So we need

  • exportFilter … [<tv-history-list>get[current-tiddler]]

  • we need to build a mailto: link

  • [ext[links]] are converted to <a href="... so we will create HTML code here, since it is easier than to create wikitext that needs to be rendered.

  • We can use some functions to define the different elements and then concatenate everything together.

  • \define mailto() mailto:name@example.com … defines the base address. name needs to be defined as needed

  • \function f.user() [{$:/status/UserName}] … returns the name from the ControlPanel setting

  • \function f.currentTiddler() [<tv-history-list>get[current-tiddler]] … reads the HistoryList current-tiddler

  • \function f.subject() "?subject=Tiddler: " [<f.currentTiddler>] " - " [<f.user>] +[join[]] … builds the mailto: subject prefix, gets current-tiddler, adds " - ", adds user-name and concatenates it to a string

  • \function f.body() "&body=" [<body-text>encodeuri[]] +[join[]] … defines the body-prefix, reads the body-text variable and uri-encodes it, so it can be used in a link

  • \function f.createMailto() [<mailto>] [<f.subject>] [<f.body>] +[join[]] … joins all functions from above together

Then we need some code that uses those functions.

<$wikify name="body-text" text="""
  <pre><code>
    {{||$:/core/templates/exporters/TidFile}}
  </code></pre>
""">
  <a class="custom-send-mail" 
    href=`${ [<f.createMailto>] }$` >{{$:/core/images/mail}}
  </a>
</$wikify>
  • wikify text= … uses the template that creates the tiddler text
  • <pre><code> … converts it to plain text
  • the A HTML element uses href=`${ [<f.createMailto>] }$` … to concatenate all the functions from above
  • Some styling is needed to create the right size and positioning of the icon in the sidebar

The full code looks like this

title: $:/_custom/ui/Buttons/save-current-tiddler
tags: $:/tags/PageControls
caption: {{$:/core/images/mail}} Mail current-tiddler
description: Mail HistoryList!!current-tiddler

\whitespace trim

\define exportFilter() [<tv-history-list>get[current-tiddler]]
\define mailto() mailto:name@example.com

\function f.user() [{$:/status/UserName}]
\function f.currentTiddler() [<tv-history-list>get[current-tiddler]]
\function f.subject() "?subject=Tiddler: " [<f.currentTiddler>] " - " [<f.user>] +[join[]]
\function f.body() "&body=" [<body-text>encodeuri[]]  +[join[]]
\function f.createMailto() [<mailto>] [<f.subject>] [<f.body>]  +[join[]]

<style>
.custom-send-mail svg {
  width: 1em;
  height: 1em;
}
.custom-send-mail {
  display: inline-block;
  vertical-align: bottom;
}
</style>
<$wikify name="body-text" text="""
  <pre><code>
    {{||$:/core/templates/exporters/TidFile}}
  </code></pre>
""">
  <a class="custom-send-mail" 
    href=`${ [<f.createMailto>] }$` >{{$:/core/images/mail}}
  </a>
</$wikify>

$___custom_ui_Buttons_mail-current-tiddler.json (1.2 KB)

have fun!
mario

1 Like

Hi @pmario,

it is working fine.
Some of my editiors wrote me that it is not working after several usage. But this is a topic for my WINDOWS Admins.

Thank you
Stefan