Jump to content

Howto: mailto ....


erich.wanker

Recommended Posts

Hello,

 

i try to create a link like: <a href="mailto:wanker@x.at" style="text-decoration: none; color: #12345"> wanker@x.at </ a>

.. but every attempt creates a new Browser Window or closes my Uni-Gui-dll..

 

 

i just want to have a UniButton or UniLabel..... user clicks on it ..... and eMailprogramm creates new Mailmessage to the eMailadress ... :-)

 

Any suggestions?

ThanX 

Erich

 

 

Link to comment
Share on other sites

I rather clumsily get round it like this.

I'm sure there is a better way but this works!

(100ms seems long enough to get the email client cranked up before the window closes)

I use the clientside click event on a Unilabel  (drawn with an underline font)

 

function click(sender, eOpts)
{
  myWin=window.open(MainForm.emailurl.text);
  setTimeout(function(){myWin.close()}, 1000);
}

 

 

Cheers

Link to comment
Share on other sites

If you want to use the Indy components then the code looks like :

I don't know much about how to send it from JavaScript so I have to work with this :

 

On a buttonClick  write these :

 

  var
                   Msg: TIdMessage;
                IdSMTP: TIdSMTP;
                TextPart: TIdText;
                HtmPart: TIdText;
 

try

     IdSMTP := TIdSMTP.Create(nil);
     idSMTP.Username := < mail user name >;
     idSMTP.Password := < mail account password >;
     idSMTP.Host     :=< outgoing mai server >;
     idSMTP.Port     := < SMTP port of mail server >;

 

 

     Msg := TIdMessage.Create(nil);
     Msg.From.address := < your mail adress >;
     Msg.Recipients.EMailAddresses := destEdit.Text;  //A TUniEdit from the form
     Msg.CCList.EMailAddresses     := ccEdit.Text;        // Same ............... 
     Msg.BccList.EMailAddresses    := bccEdit.Text;
     Msg.Subject                              := subjEdit.Text;
     Msg.ContentType := 'Multipart/Alternative';
     Msg.ClearBody;

     TextPart:=TIdText.Create(Msg.MessageParts, nil);
     TextPart.ContentType:='text/plain';
     TextPart.Body.Add('');

     HtmPart := TIdText.Create(Msg.MessageParts, bodyHTMLMemo.Lines);
     HtmPart.ContentType := 'text/html';
 

      try
          idSMTP.Connect();
          idSMTP.Send(Msg);
          ShowMessage('Message Sent -> ok');
      except on e:Exception do ShowMessage('Message Error -> '+e.message);
      end;

finally
       if idSMTP.Connected then idSMTP.Disconnect();
       IdSMTP.Free;
      TextPart.Free;
       HtmPart.Free;
       Msg.Free;
end;
 

 

in the Uses clause of the form you have to have :

 

uses

  IdMessage, IdBaseComponent,
  IdComponent, IdTCPConnection, IdTCPClient, IdExplicitTLSClientServerBase,
  IdMessageClient, IdSMTPBase, IdSMTP, IdText, IdAttachmentFile, IdAttachment

 

 

That's it ! It works;

 

 

 

 

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...