qwert

Seeking "run" method for email client

10 posts in this topic

If I want to initiate an email from a script, I can just ShellExecute a file like Draft.eml to open a compose window ... IF there's an email client installed, of course.

But what if I just want to open a general use window on the desktop for that same client? ... to read new emails, for example.

Is anyone aware of a general "run" command that doesn't require knowing which client is installed (i.e., like when eml's start the registered client, whatever it is)?

Thanks in advance for any suggestions.

 

 

Share this post


Link to post
Share on other sites



I think ShellExecute should be the way to go. If needed you can specify the "verb" parameter to define the action to be executed when the mail item is being opened.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

ShellExecute ... but what?

I don't know the identity of the email client ... and draft.eml opens a compose window, which I don't want.  What "verb" would open the whole of the client and not a specific email message? (which I don't know, either)

If I've missed your point, I apologize.  And if there's no known way, that's OK.  But it's a feature I need to figure out, so I had to ask.

Worst case, I may have to open draft.eml hidden ... and then then try to figure out what's running to support it.  But I'd prefer a direct method, of course.

Thanks for your response.

 

 

 

Share this post


Link to post
Share on other sites

Looks like the mail programs are stored in the registry: Search HKEY_LOCAL_MACHINE\Software\Clients\Mail. The default mail program seems to be flaged. Extract the program name and pass it to ShellExecute.
Sorry to not be more specific, but I have no Windows system available right now.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Another idea: What does

Shellexecute("mailto:")

return?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Search HKEY_LOCAL_MACHINE\Software\Clients\Mail

Good idea.  I looked that up and found this on  stack overflow

... with this suggestion:

Better to read HKEY_CURRENT_USER\Software\Clients\Mail. (But) this only gives you the name of the email application. If you want its executable file name, you have to go on with something like;

object mailCommand = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Clients\Mail\" + mailClient.ToString() + @"\shell\open\command", "", "none");

and then remove anything extraneous from the command-line string that you don't need (quotes, parameters).

 I'll work toward a RegRead() equivalent.

Thanks.

 

Share this post


Link to post
Share on other sites

Well, I've located the proper value (the actual run command) ... but the key path name of "Mozilla Thunderbird" presents a problem, since I don't know ahead of time what it might be ... and there could be multiple clients, I suppose.

Can someone offer a suggestion?

 

Registry_Key.thumb.png.98d7f87a9482985a7

Read_Result.thumb.PNG.64c388f2c3e990c54f

Share this post


Link to post
Share on other sites

Like this. The problem you're going to run into is you will always have some default clients in that list. Even on a brand new install I have Hotmail and Windows Mail. You would have to disregard those unless they're the only entries.

Local $sSubKey = ""
For $i = 1 to 10
    $sSubKey = RegEnumKey("HKLM\SOFTWARE\Clients\Mail", $i)
    If @error Then ExitLoop
    ConsoleWrite($sSubKey & @CRLF)
Next

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Check this key too HKEY_CURRENT_USER\SOFTWARE\Classes\mailto

Executable should be at HKEY_CURRENT_USER\Software\Classes\mailto\shell\open\command

Key does not exist when no program is set.

Edited by Manadar
Zzz

Share this post


Link to post
Share on other sites

HKEY_CURRENT_USER\Software\Classes\mailto\shell\open\command

EXCELLENT suggestion!

That nails it ... and solves the problem of multiple installed clients.

Thank you!

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now