×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Create eMail

Create eMail

Create eMail

(OP)
I require to generate an internal email to the client PC that is running my application and found this code:-
DECLARE INTEGER ShellExecute IN Shell32.dll ;
INTEGER, STRING, STRING, STRING, STRING,INTEGER
=ShellExecute(0,"Open","mailto:name@address.com?subject=Subject","","",0)

Replacing my email address for the "mailto" does not send an email but results in opening the Google page in Internet explorer.



RE: Create eMail

This is exactly what you would expect. Executing a mailto: does not send the email.It just opens the user's default email client. It is up to the user to hit the Send button.

In this case, the user's system is clearly configured to use Gmail as its default email client - hence the behaviour you are seeing.

If you want to fully automate the sending of the message, you will have to look elsewhere. There are several possible approaches. Several of them are described in the FAQs in this forum. My preferred approach is to use Mike Gagnon's method in FAQ184-4969: How to send e-mail using CDO and checking the connection status first., but it is not the only possibility.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Create eMail

Quote (Mike Lewis)

It is up to the user to hit the Send button.

And even Wikipedia's mailto article doesn't describe this unmistakably.

Quote (wiki/mailto)

...a link for sending email...

Though they continue to say:

Quote (wiki/mailto)

Clicking on the hyperlink automatically opens the default email client, with the destination email address pre-filled.

Which still isn't explicitly saying this mail isn't sent, just opened and prefilled. And you can fill in more than the recipient's mail address.

The origin is HTML, it's a special form of URL and ShellExecute can do more than just show the link for the user to click, it can "click" the link, but that still only gets you to the point a new mail item is created in the standard mail client of the user, it's not yet sent.

Mike Lewis assumes the standard mail client is Gmail, if I take you literally with "Google", then what might be the case is the user has no standard mail client set up and then the link may end up in a Google search, I don't know. If that's the case the solution is to act like a mail client and send a mail to a mailserver. CDO does allow setting a mail server address but sending a mail to a mail server requires a valid account and authentiacation, so you're depending on informations not available as there is no standard mail client set up that would have this configured, the user also will likely not be able to tell you something he doesn't know.

If you'd like to send a mail to yourself from your application for users not having mail configured on their Windows, then your solution might be connecting to "your" mail server. The mail server your own mail client uses. It comes with the problem you have to provide the authentication to the mail server you should not usually give to any others, as that means they actually send from your mail address to your mail address and if someone is willing to dig into tools logging network traffic they could find this authentication information and then send mails on your behalf to anybody without your knowledge.

So what would I do? If I want to enable users to send me a mail the ShellExecute method isn't bad, a new mail item is created, they can write what they want and send it to me. Unless they don't even have a mail client set up for themselves. Then I'd opt for the alternative of opening up a contact form on your website, which could also be done by ShellExecute of the URL to the contact form on your site.

I think many private users today use mail on the internet and don't care to have a mail client installed, they just open up gmail on their browser. That's not establishing a standard mail client for Windows. I only know one way Gmail can become your standard mail client, by configuring Windows Mail (not Outlook or Outlook Light) to have an account based on Gmail. That's still making Windows Mail the standard mail client, though, and doesn't open the browser. I have read up a bit, there are ways to let Windows open up the Outlook Web Application (OWA) as standard mail client. So maybe something like that is also doable for Gmail. Nevertheless, many users using Gmail or other web mail providers would not configure their Windows standard mail client at all. So I'd perhaps even default to a contact form.

If you only want to send informations to yourself, be aware "phoning home" features of applications easily end up in them beig considered malware by anti malware software vendors, but you can of course also again use a recipient script on your website directly without going through a web page, by using a httprequest, like a POST request, but submitting HTML forms also works with a GET request and you can even send a request body with a GET request. And what the receiving script on your website can do is up to you, it could save messages into a database or also send mails to you from your domain.

Chriss

RE: Create eMail

Quote:

Mike Lewis assumes the standard mail client is Gmail,

I thought I had picked it up from Tom's post: " ... does not send an email but results in opening the Google page in Internet explorer."

But what you are saying, Chris, is that in the absence of a default email client, the browser (in this case Internet Explorer) goes to Google's search page (not Gmail). I don't know if that's true (I have no easy way of testing it), but it sounds plausible.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Create eMail

Of course, it's not just the recipient email address (the TO: address) that is automatically filled in. You can also specify the subject, message body, CC: and BCC: fields. Tom, I know you already know this, but for the benefit of anyone else who is interested in doing this, see my article An easy way to send email from a Visual FoxPro application.

The article also mentions some limitations of this method:

- The entire mailto: link is limited to 2047 characters, so this would not be suitable for sending long messages.

- You can't apply any kind of formatting (HTML isn't supported).

- You can't use it to add attachments.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Create eMail

I don't know either, Mike.

I just don't assume "the Google page" is Gmail, but it is the Google search page. Maybe it is just the default internet page of the default browser. But it makes me wonder why you'd end up in a browser if no standard mail client is set up. Tom could easily clarify that, but I guess he's also just forwarding what a user told/wrote to him.

So, Tom, can you clarify that?

I just was in the settings of default apps, and I can't unset the standard mail client, I can only choose one of several offerings, among which is FireFox. Choosig that I get to this dialog within Firefox.


And picking Gmail and ticking "Always use this application to open mailto links" repeating the code calls up a new mail item within GMail. The standard Windows mail client stays Firefox and Firefox then acts to navigate to Gmail. So that's how that can be set up. I guess it also works with other browsers than Firefox.

That doesn't tell what happens if no default mail application aka standard mail client is set up. I don't have a juvenile Windows installation to check that, but I think since Windows Vista you'd have Windows Mail configured, without a default account. So if you stick to that you'd get to the start form of Windows Mail and are asked to create or log in to an account. I remember in older Windows systems we had Outlook Lite, but it wasn't installed by default. And as company Windows user you'd usually have the full Office Outlook application installed and never needed to care about it. But as private Windows user of older Windows you may have no mail client.

I think what is cleared up by now is how a ShellExecute of a mailto link can start a browser, not Google, but Gmail (maybe this is synonym for you Tom, I still think of Google search as the Google page). It doesn't change that a mailto link only opens up a new mail item and does not send it. And that's by design.

Well, my excessive nature this time allowed me to configure Gmail, thank you Tom, for indirectly bringing this up. And sorry, if that's all unimportant and side tracking.

Last not least, if you're running your own website and would like a script to receive messages and file them or forward them, I'd offer to post such a script in PHP or also other server side languages, like a node.js script, maybe even asp.net or classic asp, it's not much code anyway and then how to call that from a VFP executable via http request, so you could use that alternative way in your application sending a message to yourself. I recommend to always be open with this to your users and don't send something in the background without their knowledge, even if it is error reports and your intention is for the best - receiving the errors to fix them, for example. Take a look at how MS does that, maybe you don't remember, but you are asked about whether and what you allow to send to MS. While you would need expert knowlegde to verify if they don't send something else anyway, MS surely is under the microscope of consumer protection and data privacy organizations. Any communication not involving the user can be considered a malware approach of getting informations under the radar of the user.

I even once knew someone who incorporated PC visit to offer remote support, if the user likes and only when the user initiates it - and he's also available to do the support, of course. Everything done by mutual agreement and trust is okay. I have lost contact to them, but I also guess Teamviewer or other remote desktop session solutions offer informations for developers to integrate that, besides there are always the simple solutions to just give them your mail address, point them to your contact page or to the software you use for remote support.

Chriss

RE: Create eMail

Quote:

I just was in the settings of default apps, and I can't unset the standard mail client, I can only choose one of several offerings, among which is FireFox.

I just tried doing the same.

On my main system, it is offering the following applications to associate with mailto:

Firefox
Mail
Microsoft Edge
Microsoft Outlook
Postbox
Thunderbird

My normal email client is Thunderbird. But if I choose, say, Firefox, from the above list, then click on a mailto: link, it asks me to choose between Firefox, Gmail and Yahoo Mail. If I choose Firefox again, nothing appears to happen (which is not surprising, since Firefox does not know how to compose an email). But if I choose Gmail from that second list, it takes me to the Gmail site with a message composing window open and the recipient filled in - just as it would with Thunderbird or any other desktop client.

I also tried this on another machine, with broadly the same result.

So from Tom's point of view, it would seem not to make any difference whether the user is using a desktop program like Thuderbird or a web-based system like Gmail. But I've no idea what happens if there is no email association at all.

As Chris says, it would be helpful if Tom could clarify all this.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Create eMail

The list will vary, I think, MS Edge is also offered to me, so it may have become a standard of browsers to forward mailto links to whatever mail serivce the user chooses. In Firefox you could also pick a desktop application, which would just take the most roundabout way to get this done, i.e. I'd be fine to let a browser navigate to Gmail or Yahoo mail, but would configure a desktop client directly, indirect ways make no sense.

So, Tom, you may also guide your user to set up a mail client. MS offers a free version of Microsoft 365 at https://www.microsoft365.com/, there is the simple Windows Mail application and many Mozilla friends use Thunderbird, so there's a large variety of mail clients you can use for free. It's more or less easy to setup your mail accout just knowing the mail address, i.e. todays clients know a lot of the usual configurations you need for Gmail, T-Online or other major internet provider mail addresses and then your software can also start such Desktop mail clients with ShellExecute of a mailto link.

Chriss

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close