MozillaZine

How to escape ' , ' in the message - sent from command line

User Help for Mozilla Thunderbird
samikzn
 
Posts: 2
Joined: August 16th, 2017, 6:20 am

Post Posted August 16th, 2017, 6:31 am

I'm writing a small VBA code that composes an email message.
Thanks to this support, I was able to do that using a command line.
e.g.
fullpath-thunderbird -compose "to='john@example.com,kathy@example.com',cc='britney@example.com',subject='dinner',body='How about dinner tonight?'" ... woks fine as I expected

Everything looks fine - I can set To, Cc, subject, body text - it's almost perfect.
Then I found that when a comma ( , ) is in the body text, the message is truncated at that position.
e.g.
fullpath-thunderbird -compose "to='john@example.com,kathy@example.com',cc='britney@example.com',subject='dinner',body='ABC, How about dinner tonight?'" ... message body is truncated like "ABC"

Is there any way I can compose a message body text that contains ' , ' via command line?
Thank you,
-Sami

morat
 
Posts: 3472
Joined: February 3rd, 2009, 6:29 pm

Post Posted August 16th, 2017, 7:45 am

It works for me.

Code: Select all
thunderbird.exe -compose "to='john@example.com,kathy@example.com',cc='britney@example.com',subject='dinner',body='ABC, How about dinner tonight?'"

I got a vbs script working with a comma as well.

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='ABC, DEFGHIJKLMNOPQRSTUVWXYZ'" & _
  ",message=''" & _
  ",attachment=''" & _
  ",bodyislink='false'" & _
  ",type='0'" & _
  ",format='1'" & _
  ",originalMsg=''" & _
  "")
Set objShell = Nothing

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

Multiline body via command line
viewtopic.php?f=39&t=3030498

Thunderbird 52.2.1
Windows 7 SP1 32-bit

samikzn
 
Posts: 2
Joined: August 16th, 2017, 6:20 am

Post Posted August 16th, 2017, 9:23 pm

Thank you for your input. It turned out that the issue was caused by my coding. I forgot to enclose the body text using '
Then it looks working fine if the body text doesn't contain ' , '
After i modified my code to do so, then everything starts working fine.
Sorry for the confusion and thank you for your support!
-Sami

snaglist
 
Posts: 2
Joined: April 4th, 2010, 9:00 pm

Post Posted May 5th, 2019, 9:51 pm

Hi,

some more problems to this issue. I tried several versions I found in some postings but could not solve all problems at the same time.
The problems are
- cr&lf
- comma in body
- special characters in body äöü...
- attachment

If I use a comma to separate the parameters like

Code: Select all
strMail = "...\Thunderbird.exe" & _
                " -compose format=2,preselectid=id1" & _
                ",to='" & strAn & "x',subject='" & strBetr & "'" & _
                ",body='" & strBody & "',attachment='file:///" & strDatei & "'"

cr & lf not working
comma is ok
special characters ok
attachment not working.

If I use
Code: Select all
strCommand = " -compose format=2,preselectid=id1"
strCommand = strCommand & ",to='" & strAn & "y'"
strCommand = strCommand & ",subject='" & strBetr & "'"
strCommand = strCommand & ",body=" & Chr(34) & strBody & Chr(34)
strCommand = strCommand & ",attachment='" & strDatei & "'"

everything ok if there is no comma in body!

If the message is in a file like
Code: Select all
strCommand = " -compose format=2,preselectid=id1"
strCommand = strCommand & ",to='" & strAn & "y'"
strCommand = strCommand & ",subject='" & strBetr & "'"
strCommand = strCommand & ",message=" & Chr(34) & strDateiBody & Chr(34)
strCommand = strCommand & ",attachment='" & strDatei & "'"


everthing ok but no special characters in body.
They are allowed in the subject :shock: .

Maybe my "try and error" was not totally complete but I haven´t found a solution for all of my problems.

Someone´s got an idea or hint

Marc

snaglist
 
Posts: 2
Joined: April 4th, 2010, 9:00 pm

Post Posted May 5th, 2019, 11:17 pm

Some things I forgot:

the code for subject an body is

Code: Select all
strBetr = "Subject"
strBody = "Text with comma," & vbNewLine & vbNewLine
strBody = strBody & "Text" & vbNewLine & vbNewLine
strBody = strBody & "Text with äöü" & vbNewLine & vbNewLine & "Text"


I tried another version without the single ' and different body construction:
Code: Select all
strBody = "&body=" & Chr$(34) & "Body line 1" & Chr$(34) & _
"&body=" & Chr$(34) & "Line 2 " &  Chr$(34)
"&body=" & Chr$(34) & "Body line 3" & Chr$(34) & _
"&body=" & Chr$(34) & "special line öäü , " & Chr$(34) & _
"&body=" & Chr$(34) & "Line 4" & Chr$(34)

strCommand = "...\Thunderbird.exe"
strCommand = strCommand & " -compose " & Chr$(34) & "mailto:" & strTo & "?"
strCommand = strCommand & "subject=" & Chr$(34) & strSubject & Chr$(34)
strCommand = strCommand & "body=" & Chr$(34) & strBody & Chr$(34)
strCommand = strCommand & " ,attachment=" & strDatei


the result looks like
Body line 1
Line 2 Body line 3
special line öäü , Line 4" ,attachment=filemane.pdf


the attachment parameter was inside of the body

Marc

morat
 
Posts: 3472
Joined: February 3rd, 2009, 6:29 pm

Post Posted May 6th, 2019, 6:47 am

Why are you using the file and mailto uri schemes?

WRONG: attachment='file:///C:/example.txt'
RIGHT: attachment='C:\example.txt'

WRONG: to='mailto:foo <foo@invalid.com>'
RIGHT: to='foo <foo@invalid.com>'

You are omitting the single quote characters.

WRONG: preselectid=id1
RIGHT: preselectid='id1'

I got the example.vbs file working with body='ABC, äöü' and attachment='C:\example.txt' in Thunderbird 60.

Garashan
 
Posts: 2
Joined: September 16th, 2019, 6:08 am

Post Posted September 16th, 2019, 6:28 am

Dear All!
I have a VBA code in Excel what I use to call Thunderbird-compose. Here is:
Code: Select all
thund = "C:\Program Files (x86)\Mozilla Thunderbird\thunderbird.exe" & _
        " -compose " & """" & _
        "to='" & email & "'," & _
        "cc='" & cc & "'," & _
        "bcc='" & bcc & "'," & _
        "subject='" & subj & "'," & _
        "attachment='" & attch & "'," & _
        "body='" & body & "'" & """"

It's working fine, until the attachment path doesn't contain coma.
Path of the file(s):
Code: Select all
Z:\..\Árjegyzékek, terméklisták\2019\...

I can't rename the folder, because this is on a network drive. And there are many excel files with a link between workbooks.
What is the solution?

morat
 
Posts: 3472
Joined: February 3rd, 2009, 6:29 pm

Post Posted September 16th, 2019, 5:07 pm

A comma is used to separate attachment files.

Code: Select all
",attachment='C:\alpha.txt,C:\beta.txt,C:\gamma.txt'" & _

I think it isn't possible to use a comma in a folder name without an error.

You can use the batch short path without the comma.

Path Full: C:\ABC, DEFGHIJKLM
Path Short: C:\ABC_DE~1

Code: Select all
rem show full path and short path in command prompt window
cd /d C:\ABC, DEFGHIJKLM
for %i in (.) do @echo Path Full: %~fi
for %i in (.) do @echo Path Short: %~si
Last edited by morat on September 21st, 2019, 7:44 am, edited 1 time in total.

Garashan
 
Posts: 2
Joined: September 16th, 2019, 6:08 am

Post Posted September 16th, 2019, 11:32 pm

Thank you for your helping. It's working.

The easiest way to find the short path name is "dir /x" command in CMD. But I found only blank fields...

So the solution (we are using Windows Server 2012 R2):
  • Verify if the feature to create short path is enabled or not. Run the command by invoking command prompt in administrative mode:
    Code: Select all
    fsutil 8dot3name query

    0 enabled, 1 disabled, 2 per volume setting - default
  • Enable the short name
    Code: Select all
    fsutil behavior set disable8dot3 0
  • Create short name for the folder
    Code: Select all
    fsutil file setshortname "Z:\Árjegyzékek, terméklisták" ARJEGY~1
  • Restore the original state of the short name future.
    Code: Select all
    fsutil behavior set disable8dot3 2

At first I got an error, because I tried from my local computer. I switch to server machine, and I got an error: access denied.
Somebody opened an document from folder "Árjegyzékek, terméklisták". After I closed, it worked.

Return to Thunderbird Support


Who is online

Users browsing this forum: No registered users and 3 guests