Voici comment mettre son maileur perso préféré
dans les clients mail de windows.
Vous pourrez aussi le mettre par déault.
Quand vous cliquerais sur un lien Mailto:...., ce sera votre prog qui prendras la main.
Sauf pour AOL, qui boycott tout, grrrrrrr
Source / Exemple :
unit ClientMail_unit;
interface
uses Registry, windows, Sysutils;
Function MailClientExists(Nom :string):boolean;
Procedure AjoutClientMail(Nom, CheminEtParametre, Icone :string);
Procedure SetMailClientAsDefault(Nom :string);
implementation
{¨¨¨¨¨¨¨¨ Set Mail Client As Default ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨}
Procedure SetMailClientAsDefault(Nom :string);
var Reg :TRegistry;
DW :DWord;
s :string;
begin
if not MailClientExists(Nom) then
begin
MessageBoxA(0, PChar('Le Client Mail : '+ Nom + ', n''existe pas!' ),'erreur',0);
exit;
end;
DW := $02;
Reg := TRegistry.Create;
Reg.RootKey := HKEY_LOCAL_MACHINE;
Reg.OpenKey('Software\Clients\Mail',True);
Reg.WriteString('', Nom);
Reg.CloseKey;
Reg.OpenKey('SOFTWARE\CLASSES\mailto', True);
Reg.writestring('','URL:MailTo Protocol');
Reg.WriteBinaryData('EditFlags',DW, 4);
Reg.writestring('URL Protocol','');
Reg.CloseKey;
Reg.OpenKey('Software\Clients\Mail\' + Nom + '\Protocols\MailTo\DefaultIcon', True);
s := Reg.ReadString('');
Reg.CloseKey;
Reg.OpenKey('SOFTWARE\CLASSES\mailto\DefaultIcon', True);
Reg.writestring('',s);
Reg.CloseKey;
Reg.OpenKey('Software\Clients\Mail\' + Nom + '\Protocols\MailTo\Shell\open\command', True);
s := Reg.ReadString('');
Reg.CloseKey;
Reg.OpenKey('SOFTWARE\CLASSES\mailto\shell\open\command', True);
Reg.writestring('',s);
Reg.Free;
end;
{¨¨¨¨¨¨¨¨ Mail Client Exists ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨}
Function MailClientExists(Nom :string):boolean;
var HK :HKEY;
begin
RegOpenKey(HKEY_LOCAL_MACHINE,PChar('Software\Clients\Mail\'+ Nom),HK);
if HK <> 0 then result := True
else result := false;
RegCloseKey(HK);
end;
{¨¨¨¨¨¨¨¨ Ajout Client Mail ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨}
Procedure AjoutClientMail(Nom, CheminEtParametre, Icone :string);
var Reg :TRegistry;
buf :Array[0..3]of byte;
DW :DWord;
begin
DW := $02;
Reg := TRegistry.Create;
Reg.RootKey := HKEY_LOCAL_MACHINE;
Reg.OpenKey('Software\Clients\Mail\'+ Nom, True);
Reg.WriteString('', Nom);
Reg.CloseKey;
Reg.OpenKey('Software\Clients\Mail\' + Nom + '\Protocols\MailTo', True);
Reg.writestring('','URL:MailTo Protocol');
Reg.WriteBinaryData('EditFlags',DW, 4);
Reg.writestring('URL Protocol','');
Reg.CloseKey;
Reg.OpenKey('Software\Clients\Mail\' + Nom + '\Protocols\MailTo\DefaultIcon', True);
Reg.writestring('',icone);
Reg.CloseKey;
Reg.OpenKey('Software\Clients\Mail\' + Nom + '\Protocols\MailTo\Shell\open\command', True);
Reg.writestring('','"' + CheminEtParametre + '" "%1"');
Reg.CloseKey;
Reg.OpenKey('Software\Clients\Mail\' + Nom + '\Shell\open\command', True);
Reg.writestring('',CheminEtParametre + ' -MailBox');
Reg.CloseKey;
Reg.Free;
end;
end.
Conclusion :
pour mettre son prog dans les Clients Mail:
AjoutClientMail('Mail DelphiCool', 'paramsrtr(0)', 'chemin de votre icone');
pour mettre votre maileur par défaut:
SetMailClientAsDefault('Mail DelphiCool');
la ligne de commande sera dans paramstr(1)
PS : si vous avez un liens de ce type : mailto:delphicool@monmail.com?subject?hello&cc=cool@mail.lol&body=et%20voici%20le%20texte%20avec%20des%20espaces.
il faudras décortiquer la ligne de commande
pour extraire tout les element
et remplacer les %.. par le caractere adequat (c'est de l'hexa)
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.