Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

TWebBrowser - invoking mail client

Posted on 1998-08-18
3
Medium Priority
?
164 Views
Last Modified: 2010-04-04
When a user clicks on email links on a web page, a default mail client is invoked. This default mail client is tored somewhere in the registry.

In my application, I have two forms, one is a web browser using TWebBrowser, and the other one is a mail client. So two forms in the one application.  Instead of invoking a different exe mail client when the user clicks on a mail link, I want to have the MailForm.Show called.

Thank you.
0
Comment
Question by:sharons
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
d003303 earned 1000 total points
ID: 1337184
Yo,
do it like this:

// form code
object Form1: TForm1
  Left = 200
  Top = 108
  Width = 783
  Height = 551
  Caption = 'Form1'
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  PixelsPerInch = 96
  TextHeight = 13
  object WebBrowser1: TWebBrowser
    Left = 0
    Top = 41
    Width = 775
    Height = 483
    Align = alClient
    TabOrder = 0
    OnBeforeNavigate2 = WebBrowser1BeforeNavigate2
    ControlData = {
      4C00000019500000EB3100000100000005000000000000000000000000000000
      000000004C000000000000000000000001000000E0D057007335CF11AE690800
      2B2E126208000000000000004C0000000114020000000000C000000000000046
      8000000000000000000000000000000000000000000000000000000000000000
      000000000000000001000000000000000000000000000000}
  end
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 775
    Height = 41
    Align = alTop
    TabOrder = 1
    object Edit1: TEdit
      Left = 8
      Top = 8
      Width = 537
      Height = 21
      TabOrder = 0
    end
    object Button1: TButton
      Left = 564
      Top = 8
      Width = 75
      Height = 25
      Caption = 'Go!'
      TabOrder = 1
      OnClick = Edit1Enter
    end
  end
end

// unit code
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  OleCtrls, SHDocVw_TLB, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    WebBrowser1: TWebBrowser;
    Panel1: TPanel;
    Edit1: TEdit;
    Button1: TButton;
    procedure Edit1Enter(Sender: TObject);
    procedure WebBrowser1BeforeNavigate2(Sender: TObject; pDisp: IDispatch;
      var URL, Flags, TargetFrameName, PostData, Headers: OleVariant;
      var Cancel: WordBool);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Edit1Enter(Sender: TObject);
var V1, V2, V3, V4 : OLEVariant;
begin
  V1 := 0;
  V2 := 0;
  V3 := 0;
  V4 := 0;
  WebBrowser1.Navigate(WideString(Edit1.Text), V1, V2, V3, V4);
//  WebBrowser1.Navigate(WideString(Edit1.Text), );
end;

procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
  pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
  Headers: OleVariant; var Cancel: WordBool);
var URLString : string;
begin
  URLString := URL;
  if Pos('mailto', URLString) <> 0 then
   begin
     // mailto clicked
     Cancel := true;
     // invoke mail window with URLString
   end;
end;

end.

// project code
program Project1;

uses
  Forms,
  unit1 in 'unit1.pas' {Form1};

{$R *.RES}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

Have fun,
Slash/d003303
0
 
LVL 4

Expert Comment

by:d003303
ID: 1337185
or, to be more safe, instead of

  if Pos('mailto', URLString) <> 0 then

use

  if UpperCase(Copy(URL, 1, 7)) = 'MAILTO:' then

Slash/d003303
0
 

Author Comment

by:sharons
ID: 1337186
Thank you. It works great.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question