Sign in to follow this  
Followers 0

Open Mail Client

13 posts in this topic

Posted (edited)

My Simple UDF to open the defult mail Client.

Downloads: Posted Image

Download

(Direct: http://signa5.com/downloads/_OpenDefaultMail.au3)

I needed it for a script never that eventuated into anything.

EDIT: Updated 10 November 2008. Now hosted by my site, and using suggestions from MsCreator.

Cheers,

Brett

Edited by BrettF

Share this post


Link to post
Share on other sites



Posted

Usefull.

But I discovered in my registry that for Opera is missing shell\open\command key

and there is only Protocols\MailTo\shell\open\command with value "C:\PROGRAM FILES\OPERA\OPERA.EXE" "%1"

So due to "%1" it's not possible to use Run()

Ideas:

Also you should make SetError() in some cases (after RegRead):

If @error Then 
	SetError(1)
	Return
EndIf

And maybe make FileExists() test before Run(), but this is maybe unnecessary because in these registry keys should be always correct paths (to existing EXE's).

Share this post


Link to post
Share on other sites

Posted

Usefull.

But I discovered in my registry that for Opera is missing shell\open\command key

and there is only Protocols\MailTo\shell\open\command with value "C:\PROGRAM FILES\OPERA\OPERA.EXE" "%1"

So due to "%1" it's not possible to use Run()

Ideas:

Also you should make SetError() in some cases (after RegRead):

If @error Then 
	SetError(1)
	Return
EndIf
oÝ÷ Ø	ݬzf¤xX¥xLb²Û-zË[yú+y§nëm+"²f²më§ç²Æ«É·jë{azÇ«z¬¶¼¤{+,¥u·²±Ê+­ç-¥«a²ÚÆ+-xMý³ú®¢×jy쨺¸ÖX§y«­¢+Ù%ÉɽÈQ¡¸IÑÕɸMÑÉÉ½È Ä°Ä°À¤

Share this post


Link to post
Share on other sites

Posted

can make your if 1 line

If @error Then Return SetError(1,1,0)
I know, it looks better and it's easier to read my way...

Share this post


Link to post
Share on other sites

Posted

You should use before Run():

Opt("RunErrorsFatal",0)

to avoid hard crash if file not exists. Then your test for @error after Run() will work.

Share this post


Link to post
Share on other sites

Posted

You should use before Run():

Opt("RunErrorsFatal",0)

to avoid hard crash if file not exists. Then your test for @error after Run() will work.

Thankyou, This is my first upload so....

Share this post


Link to post
Share on other sites

Posted

Thankyou, This is my first upload so....

Or another way to catch it (instead of Opt("RunErrorsFatal",0)):

If Not FileExists($mailKey) Then
  SetError(3)
  Return
EndIf

before Run()

Share this post


Link to post
Share on other sites

Posted (edited)

@Bert

In your UDF there is a potential problem - when you return, the Opt() is not restored to initial value :P

And for the other clients, such as Opera Mail, this function should cover the most possible pathes:

Func _LaunchDefaultMailClient()
	Local $Old_Opt_EES = Opt("ExpandEnvStrings", 1)
	Local $Old_Opt_REF = Opt("RunErrorsFatal", 0)
	Local $iRetError = 0, $iRetValue = 0
	Local $ReadDefMailClient, $ReadCommand
	
	$ReadDefMailClient = RegRead("HKLM\SOFTWARE\Clients\Mail", "")
	If @error Or $ReadDefMailClient = "" Then $iRetError = 1
    
	If $iRetError = 0 Then
		$ReadCommand = RegRead("HKLM\SOFTWARE\Clients\Mail\" & $ReadDefMailClient & "\shell\open\command", "")
		If @error Or $ReadCommand = "" Then $iRetError = 2
	EndIf
    
	If $iRetError = 0 Then
		If StringRegExp($ReadCommand, '"(.*)"') Then _
			$ReadCommand = StringMid($ReadCommand, 2, StringInStr($ReadCommand, '"', 0, 2)-2)
		If StringInStr($ReadCommand, '/') Then _
			$ReadCommand = StringLeft($ReadCommand, StringInStr($ReadCommand, '/', 0, -1))
	EndIf
	
	If $iRetError = 0 Then
		$ReadCommand = StringStripWS($ReadCommand, 3)
		If Not FileExists($ReadCommand) Then $iRetError = 3
	EndIf
	
	If $iRetError = 0 Then
		Local $iRetValue = Run($ReadCommand)
		If @error Then $iRetError = 4
	EndIf
	
	Opt("ExpandEnvStrings", $Old_Opt_EES)
	Opt("RunErrorsFatal", $Old_Opt_REF)
	
	Return SetError($iRetError, 0, $iRetValue)
EndFunc
Edited by MsCreatoR

Share this post


Link to post
Share on other sites

Posted

Thanks Mate. I created this a long time ago, before I actually got somewhere with this...

Share this post


Link to post
Share on other sites

Posted (edited)

Things do change, squirrely guy who says this in his sig: "Revolt NOW!" - no such thing as aliens

ShellExecute("mailto:me@mydomain.com"); launches client with address
ShellExecute("mailto:"); launches client WITHOUT address
Edited by Squirrely1

Share this post


Link to post
Share on other sites

Posted

Bit of an old bump, but thanks? I guess...

Share this post


Link to post
Share on other sites

Posted (edited)

Bit of an old bump, but thanks? I guess...

Pardone me, monsieur - I presume by this that you mean that like I went searching through old threads to dig up this one ?

In your defense, we have this: I think that the function "ShellExecute" became available to us not very long ago.

And we have this as against me: I was not the first to use the function on a HREF attribute.

Edited by Squirrely1

Share this post


Link to post
Share on other sites

Posted

Hey Guys,

Just updated the function. It is now hosted by my site, and using suggestion from MrCreator.

Cheers,

Brett

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
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.