Multiline body via command line(thunderbird -compose)(Linux)

User Help for Mozilla Thunderbird
Post Reply
chyavana
Posts: 3
Joined: May 22nd, 2017, 12:35 am

Multiline body via command line(thunderbird -compose)(Linux)

Post by chyavana »

I have the same question in May 2017.

I am on Manjaro Linux and want to automate the sending of a few customized email messages from the command line.

The `-compose` command with the `body` option should do it, but I have a multi-line string that has been loaded from a text file so:

`body=$(<textfile)`

Only the first line is shown on the message window.

How should I proceed?

Thanks.
Last edited by DanRaisch on May 22nd, 2017, 3:47 am, edited 2 times in total.
Reason: Split from original thread which died 2 years year ago.
chyavana
Posts: 3
Joined: May 22nd, 2017, 12:35 am

Re: Multiline body via command line(thunderbird -compose)(Li

Post by chyavana »

Here is my progress to date:

body=\"$(sed ':a;N;$!ba;s/\n/%0A/g' < textfile)\" # See http://stackoverflow.com/questions/1251 ... 91#1252191
thunderbird -compose body="$body"

This works almost exactly as I want it to but there is a pair of double quotes at the beginning and very end of the body text. Any help to remove these automatically is most appreciated.
morat
Posts: 6436
Joined: February 3rd, 2009, 6:29 pm

Re: Multiline body via command line(thunderbird -compose)(Li

Post by morat »

You can use the message argument to specify a plain text or an HTML file for the body of the mail.

http://kb.mozillazine.org/Command_line_ ... hunderbird

Here is a VBScript example.

http://en.wikipedia.org/wiki/VBScript
http://ss64.com/vb/

* example.vbs

Code: Select all

Option Explicit

Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Exec("%ProgramFiles%\Mozilla Thunderbird\thunderbird.exe -compose" & _
  " preselectid='id1'" & _
  ",from=''" & _
  ",to='foo <foo@invalid.com>'" & _
  ",cc=''" & _
  ",bcc=''" & _
  ",newsgroups=''" & _
  ",subject='Example'" & _
  ",body=''" & _
  ",message='C:\example.htm'" & _
  ",attachment='C:\example.txt'" & _
  ",bodyislink='false'" & _
  ",type='0'" & _
  ",format='1'" & _
  ",originalMsg=''" & _
  "")
Set objShell = Nothing
* example.htm

Code: Select all

This text is <b>bold</b><br>
This text is <i>italic</i><br>
This text is <u>underline</u><br>
This text is <strike>strikethrough</strike><br>
* example.txt

Code: Select all

This is an attachment file.
Similar thread: http://forums.mozillazine.org/viewtopic ... &t=3012527

Reference:

http://dxr.mozilla.org/comm-release/sou ... ommands.js
chyavana
Posts: 3
Joined: May 22nd, 2017, 12:35 am

Re: Multiline body via command line(thunderbird -compose)(Li

Post by chyavana »

You can use the message argument to specify a plain text or an HTML file for the body of the mail.
...
message='C:\example.htm'
Thank you @morat. Those two lines above clinched it for me. And the solution is so simple. You made my night!
Post Reply