Jump to content

Open Mail Client


BrettF
 Share

Recommended Posts

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
Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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²Û-[+y§nëm+"²f²më§ç²Æ«É·jë{azÇ«z¬¶¼¤{+,¥u·²±Ê+­ç-¥«a²ÚÆ+-xMý³ú®¢×jy쨺¸ÖX§y«­¢+Ù%ÉɽÈQ¡¸IÑÕɸMÑÉÉ½È Ä°Ä°À¤

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

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....
Link to comment
Share on other sites

  • 10 months later...

@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

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 4 months later...

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

Das Häschen benutzt Radar

Link to comment
Share on other sites

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

Das Häschen benutzt Radar

Link to comment
Share on other sites

  • 6 months later...
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...