Carriage Returns stripped from Command Line generated e-mail

Discussion of bugs in Mozilla Thunderbird
Post Reply
erock
Posts: 1
Joined: March 29th, 2006, 7:03 pm

Carriage Returns stripped from Command Line generated e-mail

Post by erock »

I've been attempting to send e-mail via Thunderbird from an Access db using VBA (see bottom of thread for function). It is not going so well, because Thunderbird loves to eat carriage returns/line feeds.

I was running Thunderbird 1.0 and generating e-mail successfully, however, carriage returns (originally vbCrLf in the VBA) were being stripped out of the text of the e-mail body. The e-mail would come out as a giant block of text, without fail. I searched around in the forums here and noticed that there are innumerable posts about people losing their carriage returns in this program, and no one has had an answer. I've decided this has to be a bug.

To make it worse, I just downloaded and installed the most recent build of Thunderbird (1.5) hoping this might have been fixed in subsequent builds, and now I'm losing almost the entire body of the e-mail! It looks like after the first carriage return/line feed, it is just losing the rest of the string.

Any known workarounds or is this really and truly a bug worthy of mention?

Thanks,

Eric

==========
Sample VBA begins here:

Public Function fSendThunderbird(strTo As String, strSubject As String, strBody As String)

'This function can be used to send an e-mail from Mozilla Thunderbird.
'The syntax for calling Thunderbird from a command line (DOS prompt) is:
'
'thunderbird -compose "mailto:somebody@somewhere?cc=address@provider&subject=hi&body=something"
'
Dim strCommand As String

strCommand = "C:\Program Files\Mozilla Thunderbird\thunderbird"

strCommand = strCommand & " -compose " & Chr$(34) & "mailto:" & strTo & "?"
strCommand = strCommand & "subject=" & Chr$(34) & strSubject & Chr$(34) & "&"
strCommand = strCommand & "body=" & Chr$(34) & strBody & Chr$(34)

Call Shell(strCommand, vbNormalFocus)

End Function
472dmr
Posts: 2
Joined: June 14th, 2006, 1:09 am

Carriage returns stripped from command line generated e-mail

Post by 472dmr »

Using &body multiple times avoids the issue with carriage returns. The following code (from Excel using VBA) will generate an e-mail with two recipients and an e-mail body as follows:
Body line 1
Body line 2
Body line 3

Signature 1
Signature 2
Signature 3

Public Function fSendThunderbird()
Dim strCommand As String ' Command line to prepare Thunderbird e-mail
Dim strTo As String ' E-mail address
Dim strSubject As String ' Subject line
Dim strBody As String ' E-mail body

strTo = "test@test.com, test2@test.com"
strSubject = "Test subject"

strBody = "&body=" & Chr$(34) & "Body line 1" & Chr$(34) & _
"&body=" & Chr$(34) & "Body line 2" & Chr$(34) & _
"&body=" & Chr$(34) & "Body line 3" & Chr$(34) & _
"&body=" & Chr$(34) & " " & Chr$(34) & _
"&body=" & Chr$(34) & "Signature 1" & Chr$(34) & _
"&body=" & Chr$(34) & "Signature 2" & Chr$(34) & _
"&body=" & Chr$(34) & "Signature 3" & Chr$(34)


strCommand = "C:\Program Files\Mozilla Thunderbird\thunderbird"
strCommand = strCommand & " -compose " & Chr$(34) & "mailto:" & strTo & "?"
strCommand = strCommand & "subject=" & Chr$(34) & strSubject & Chr$(34)
strCommand = strCommand & strBody
Call Shell(strCommand, vbNormalFocus)

End Function
Post Reply