1

I've this problem:

I'm trying to send an email from the command line but if I do:

mailto: example@rat.it?subject=subject&body=body

The cmd returns me: "body" non è riconosciuto come comando interno o esterno, un programma eseguibile o un file batch.

I only manage to write an email with the subject and without the body, How can I add the Body?

Please help me

Bobo87
  • 151
  • 3
  • 13
  • Is this linux, or what is "mailto:" (it doesnt work in Win)? – Jim W Nov 04 '13 at 15:55
  • I need to work this on Win! is this possible? – Bobo87 Nov 04 '13 at 15:57
  • Well, according to http://support.microsoft.com/kb/287573 what you have is correct, however for me mailto: doesn't even do anything, so I can't try it, sorry. – Jim W Nov 04 '13 at 16:03
  • 1
    @JimW try `start mailto:example......` and you'll get the errormessage about "body". And you are right - according to the microsoft-article it should work. – Stephan Nov 04 '13 at 16:29

2 Answers2

6

almost there...

This works:

  start mailto:"example@rat.it?subject=subject&body=body"

EDIT: but it puts an extra "to the beginning of the address... (you can avoid the extra " at the end of the body by inserting a space in front of it)

EDIT2: but this works:

start "" "mailto:example@rat.it?subject=subject&body=body "
Stephan
  • 53,940
  • 10
  • 58
  • 91
  • How can I attach a file to the mail? If I try to do add &attachment="file.txt" ...this doesn't work! – Bobo87 Nov 05 '13 at 15:47
  • according to the microsoft-article mentioned by Wim W, attachment is not an option. – Stephan Nov 06 '13 at 10:55
  • so...attaching a file is not possible? – Bobo87 Nov 06 '13 at 10:58
  • google found: "There is no official way to attach files using "mailto" protocol. Most likely because of the security reasons. However some email clients do accept the attachment parameter with the file in quotes i.e. attachment="C:\fileName.txt" such as outlook 98." - you may try different EMailPrograms. – Stephan Nov 06 '13 at 11:11
  • Thanks a lot for this answer! This was the only way all parameters worked correctly – Nightmare_82 Aug 13 '21 at 22:38
0

The Interlink mail client does this. https://binaryoutcast.com/projects/interlink

  • To describe Interlink:
    • works like classic Thunderbird, but better
    • under current development
    • longstanding TB bugs have been fixed
    • not a clone, and not a recent fork

From the docs at http://kb.mozillazine.org/Command_line_arguments_%28Thunderbird%29 and testing on Windows:

d:\Path\Interlink.EXE -compose ^
"from='From Name ^<FromBox@FromDomain.com^>'^
,to='To Name One ^<ToBoxOne@ToDomainOne.com^>, To Name Two ^<ToBoxTwo@ToDomainTwo.com^>'^
,cc='CC Name One ^<CCBoxOne@CCDomainOne.com^>, CC Name Two ^<CCBoxTwo@CCDomainTwo.com^>'^
,bcc='BC Name One ^<BCBoxOne@BCDomainOne.com^>, BC Name Two ^<BCBoxTwo@BCDomainTwo.com^>'^
,subject='Your Subject Here'^
,message='d:\Path\Body File.htm',^
,attachment='^
d:\Path\Attach One.PDF,^
d:\Path\Attach Two.PDF^
'"

Line continuation is for readability and bat/cmd files, but also works correctly. The angle brackets do not need to be escaped inside single-quotes in a Set statement.

BUG: The from-address must exist in an Identity, or else the resulting compose window will be empty. This bug was filed in the queue around July 2020. When the from-address is found in an Identity, the From-Name is copied from the Identity, and the From-Name on the command line is ignored.

Syntax:

  • The entire list of arguments to -compose is enclosed in double-quotes. Within the argument-list, the arguments are separated by commas; the commas can-not be led nor followed by spaces. When the argument-list contains only one argument, and that argument contains zero spaces or angle brackets, enclosing it in double-quotes is optional.

  • Within an argument, the list of values is enclosed in single-quotes. Within a value-list, the values are separated by commas; the commas can-yes be followed by spaces. When a value-list contains only one value, and that value contains zero spaces or angle brackets, enclosing it in single-quotes is optional.

  • Some arguments will accept all values in a value-list: to=, cc=, bcc=, attachment=

  • Some arguments will accept only the first value in a value-list: from=, subject=, body=, message=; following values are ignored.

  • If both message= and body= are specified, then body= is ignored.

Thunderbird is likely compatible.

Get the executable pathname from the registry into an environment variable with:

For /F "Tokens=3" %%A In ('Reg Query HKEY_CLASSES_ROOT\mailto\shell\open\command') Do Set MailerEXE=%%A
Bilbo
  • 358
  • 1
  • 10