Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email automation with OUTLOOKNEW

Status
Not open for further replies.

sdocker

IS-IT--Management
Aug 12, 2010
214
0
0
GB
I have been using ShellExecute to automate outlook emails from within a FoxPro app. Everything was fine until we upgraded to Windows 11 and had to switch to OutLookNew. Now we gat a message that this feature is not supported.

Any ideas will be greatly appreciated.

Sam
 
First of all, please be precise about the error and source of error.

There is an error number 1001 in VFP with the message "Feture is not available" which happens, for example, when you have a line SET STEP ON and run the EXE, not the IDE. That's gone in VFP9, but would still cause this error in VFP8 or older, I think.

ShellExecute never was the best way of creating mails, albeit a simple, executing "mailto:" URLs that can even trigger to bring up gmail.com, see thread184-1829430

ShellExecute is stil present in Windows 11, I wouldn't even look if you told me in Windos 20 whether it is an API function that's gone. It's the same function that is used by Windows Explorer when you double click any file and triggers the start of the application asociated with the file extension. If MS would remove that, there would need to be a drastic change in the overall Windows API world to justify that.

I bet you just have forgotten to remove a SET STEP ON. It would be better to set break points instead.

Chriss
 
Also, what exactly do you mean by "OutLookNew"? I know that Outlook mail (and calendar) is now part of Windows, rather than a separate product or part of Office or Microsoft 365. But the way you have phrased your question suggests it is something more than that.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
This is the code being used. There is no SET STEP. It used to open a "New Email" window and all I had to do was drag the attachment and click "Send".

Code:
	lcMail = "mailto:"+ email + ;
		'?Subject= '+ emSubject + ;
		'&Body=Dear Customer,%0A%0A' + ;
		'The attached PDF file is your renewal order/reminder for '+ ;
		'Shopping List for the '+emYear +'.' + ;
		'%0A%0AThe quickest and cheapest way to order is online at:      [URL unfurl="true"]www.shop-up.com'[/URL] + ;
		'%0A%0AYour timely response will be appreciated.%0A%0AEasy Shopping'

	ShellExecute(0,"open",lcMail,"","",1)

Now, all I get is multiple Blank windows that eventually partly populates and then a blank window that says:

This action isn't supported yet​
The New Outlook for Windows doesn't currently support this action. You can switch back to Classic Outlook for Windows and try again.​

Thanks,
Sam
 
Well, the first thing to do is to check what action is assigned to the "mailto:" protocol - and to change it if necessary.

You can do that in Settings > Default Programs > Set Associations > Protocols. Scroll down until you see "mailto:". Presumably it is pointing to "New Outlook for Windows" or something similar. If so, click "Change Program" to choose a different program. Ideally, choose the old version of Outlook (what they call "Classic Outlook"; or it might just be labelled "Microsoft Outlook) if you have that installed (or can easily install it). If not, consider installing a third-party email client (such as Thunderbird or Postbox).

The point is that won't matter what email client you use here. ShellExecute() simply calls that client and tells it to open a message composing window. The actual message will be the same regardless, as will the subsequent user action.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Well, that in short means this new Outlook version is not programmed with MAPI standards. Bad move, Microsoft.

Well, what you can do as you are your own "customer" and just need this machanism to work again, is install any MAPI complient mail client, of which there are a lot.

As already pointed out in the recent thread you can setup Windows to use gmail as standard mail client and will get a mail tab in your standard browser, gmail also supports drag&drop of attachment files. That doesn't even require a software installation. Another very popular MAPI complient mail client is thunderbird, which also is free.

Both gmail and thunderbird can be configured to use your mail address (yes, indeed gmail is not only capable to maintain gmail addresses).

Chriss
 
There is an easy way for you to test what Chris and I have both posted above.

Simply create a text file, and type this code into it:

[tt]<p><a href="mailto:anyname@example.com">Click here to send email</a></p>[/tt]

(The actual email address doesn't matter. It is just for testing.)

Save the file with extension HTML.

Next, find the file in the File Explorer and double-click on it. This will open it in your browser. Now click the text where indicated. This should launch the message composing window in the program associated with the mailto: protocol.

If you see the same "This action isn't supported yet" message, then you will know that the problem has nothing to do with VFP or with ShellExecute(). In that case, the solution would be to change to a different email client, as explained above.

If, on the other hand, you get a satisfactory composing window in the new Outlook, then the problem must lie in the other parameters that you specified in the mailto: link, such Subject and Body. I think that is very unlikely, but it would be worth checking.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
You could also just paste the [tt]mailto:anyname@example.com[/tt] URL into the address bar of your browser to see it start the standard mail client of Windows.



Chriss
 
Thanks everyone.

I will read and digest all the info. Im sure something will work.

Sam
 
By teh way, the use of mailto: URLs and ShellExecute is not strictly "automation" in the sense of COM automation, which is done by first creating automation server like you can also build with VFP when you design a class to be olepublic.

So, in short, COM automation would first create an outlook instance with CREATEOBJECT("Outlook.Application"), executing a mailto: URL is just making use of the MAPI meachnism this is triggering to start the mail client defined as Windows standard mail client and creating a new mail item on the standard mail account. It's also automatic, so in that sense automation, sure, but it's not the gold standard COM automation you could use.

According to this version of outlook indeed loses the COM automation available for the standard Outlook Desktop applications. It's instead based on WebView2, like the Edge browser and this article expects there to be a javascript based automation mechanism.

Anyway, when you build a new mail client, and I'm sure MS has reused a lot of the Outlook codebase, no matter if the UI and interface changed, at least mailto: URLS should work, the ShellExecution of mailto: URLs also worked with Outlook Express, if you remember that as the small (and free) brother of the fully fledgbed Office Outlook, mailto: alsop worked with Windows Mail, if you also remember that - and I think that also still is available - as part of the Windows Live / Windows Essential. We've already been through a lot of ups and downs on Microsoft deciding for and against such bundles of software that enable private users to have all the essential functionalities they need without having Office or even an Office susbcription. And indeed the pressure of the free Google suite of docs/sheets/gmail and other such suites like OpenOffice or LibreOffice and more.

I just took a stab at googling Microsoft revenues and see MS makes most money with their cloud computing platform, more than with sales of Windows and Office combined. So this software landscape change seems to me a step to get everything more integrated into the cloud (web) than to the desktop, basing that Office on WebView2 is clearly a step in that direction. We'll likely see a shoft away from COM in more aspects in the coming years.

Still, it shouldn't even affect you with not using COM automation but the mechanism to trigger the standard mail client. That's a loss in quality, to me. They might have their reasons to bury COM, but when you undermine such mechanisms that's putting users into a situation where they need third party software that still supports standards Microsoft even was involved with defining and integrating into Windows and their own software suites, even those free express versions MS also always offered.

Chriss
 
You could also just paste the mailto:anyname@example.com URL into the address bar of your browser

Yes, of course. I should have thought of that as well.

In fact, you could even simply click on the link as posted in this thread. Or on any other email address on any website. (Remember, clicking a mailto: link doesn't actually send an email; it just opens the message composing window.)

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top