Simple "MAILTO:" with Attachment

Dave I am not sure from the OS X CLI how to list the user’s installed Mail programs but I also use Outlook on my mac.

This is how to open Outlook 2011

 open -a Microsoft\\ Outlook filename

Thanks for all the responses… at this time I am going to forego this feature of my app…

I was thinking you could issue the shell open for every mail app and parse through the failed messages thus trying the next until you are successful. Thus manually managing this via code since you are the MacGyver of Xojo :slight_smile:

open -a thunderbird filename (is the mozilla client)

You haven’t even touched on what happens if they use a web interface for their email (like I do). :slight_smile:

Yeah… I noted that above about Outlook 365. :slight_smile: Yours is much more elaborate and I have copied it for future use. Thanks!

Oops, apparently you did touch on what happens. LOL

A simple description of why you want to do something would be extremely helpful. We try to help you, but if you only want one direction please say so beforehand.

Do you really think you would send out more than a couple of thousand mails each month?

I don’t wish to send any emails…let alone thousands…

The app needs to allow the user to select a database, a table or a single record and export it to an encrypted textfile (This feature already exists in the app).

Then I wish to provide the user with the option of emailing that file (hence the attachment) to another user of the same application at another location. At which point THAT user will then import the encrypted data into their copy.

This way the data (email attachment) is never in clear text, and is usable only by another user of this exact same application (via use of public key encoded into the document) and a private key encoded inside the application.

This feature will probably not be used by 99% of the users… but for the remaining 1% it would provide a way to share sensitive data easily.

So the idea is …

  1. the user selects a database/table/record
  2. selects EXPORT function
  3. an encrypted text file is created
  4. their email client is opened with a basic email created, with the text file already set as an attachment
  5. the user fills in the recipients email address
  6. clicks SEND in their email client

Steps 1-3 are done, work etc…
Steps 4-6 are to make it easy on the user. I could simply tell them “Hey take this file and email” and let them manually open email client, create email, drag file to attachment etc.

Maybe you could set up the email with the subject for them, then instead of having the file attached (which would be nice but seems impossible/difficult to do) open the folder with the export file highlighted so it’s easy for them to just drag it into the email…no looking to see where it was saved or anything, it would be highlighted and ready to drag into the message.

[quote=83947:@Beatrix Willius]A simple description of why you want to do something would be extremely helpful. We try to help you, but if you only want one direction please say so beforehand.
[/quote]
In Dave’s defense, he did state clearly up front that he wanted to open the user’s email client. That should have indicated that he didn’t want to send the email himself, which we all know how to do via smtpsocket, but there are very good reasons to go through the user’s client and put the user in charge.

Other programs are able to do this, but I don’t know how it is done. Sorry.

Perhaps a pertinent comment here: remember that URLs have a character limit of about 2000 characters, so using MAILTO may not always be suitable, if you’ve got a lot of body text.

Using Thunderbird you can create a new Mail with command line arguments. The argument -compose has a attachment value too.

  dim Mailprog as String = "C:\\Program Files (x86)\\Mozilla Thunderbird\\thunderbird.exe"
  dim s as String = "-compose to='email1@email.com,email2@email.com',subject='TEST',body='EMAILTEXT',attachment='C:\\Users\\mh\\Pictures\\SetupString.PNG',preselectid='id2'"
  dim MProg as FolderItem
  
  MProg = GetFolderItem(Mailprog)
  Mprog.Launch(s)

mozillaZine

This thread is pretty old but here is a vbscript option for Windows that is more generic than Thunderbird:

https://social.technet.microsoft.com/Forums/scriptcenter/en-US/…

For Windows is this of any use?

https://sites.google.com/site/itmanagerslife/home/sendtovb

You don’t need any VBA or VBS script. For windows you can use:
outlook.exe /m info@xojo.com /a “C:\Users\<USERNAME\Desktop\WinAttachment.txt”

For Office 2013:
“C:\Program Files\Microsoft Office 15\root\office15\outlook.exe” /m info@xojo.com /a “C:\Users\<USERNAME\Desktop\WinAttachment.txt”

And if you are not using Outlook?

Mozilla Thunderbird:
thunderbird -compose “to=‘john@example.com,kathy@example.com’,cc=‘britney@example.com’,subject=‘dinner’,body=‘How about dinner tonight?’,attachment=‘C:\temp\info.doc,C:\temp\food.doc’”

Ritlabs - The Bat!
bat.exe /MAILU=MyAccount;TO=some@address.com;S=Test;T=some_template_file;A=some_attached_file

Pegasus:
pmail -A -F %IMGPATH% -B -S " PrintScreen Attached" me@example.com

Ubuntu Linux:
mutt -a myfile.txt -s “Here’s my file” – me@example.com
or
mail -s “hello” RECEIVE@mail.com -a /home/masoud/YOURFILE.txt

Why so complicated? I do not know if this was said before but I just use mailto: URI with websafe parameters:

mailto:someone@domain.de?subject=My%20Subject&body=Hi%20Body&attachment=\\myhost\myfolder\myfile.txt

This works crossplatform with any properly installed mailclient on any target platform. Of course if there is no Outlook, Firebird or something else nothing else tied with mailo: Handler nothing will happen.

I do not use this in Commandline but in ShowURL()

EDIT: reading a bit backward I see that this is not officially supported by IANA…
Sorry!

Try this HTML mailto examples

Robert