Scalabium Software

SMExport advertising

Knowledge for your independence.
Home Delphi and C++Builder tips



#49:How can I create the email message?

If you need create the message in your mailing app from your Delphi code, you can:

1. create a message via default mailer using shell api:

uses ShellAPI;
var
  pCh: PChar;
begin
  pCh := 'mailto:mshkolnik@scalabium.com?subject=your_subject&body=your_body';
  ShellExecute(0, 'open', pCh, nil, nil, SW_SHOWNORMAL);
end;

Few additional comments:
1. the some mailers supports the extended syntax with some usefule features. For example, the MS Outlook supports the file attachment via ShellExecute:

var
  pCh: PChar;
begin
  pCh := 'mailto:mshkolnik@scalabium.com?subject=your_subject&body=your_body&file="c:\autoexec.bat"';
  ShellExecute(0, 'open', pCh, nil, nil, SW_SHOWNORMAL);
end;

But other mailers don't supports this file attachment.

2. you must convert a texts which you want to place into subject or body - to change a spaces into "%20"

3. on some builds of MS Windows the all characters from subject and body will be trancated to small length or converted to lower case

2. create a message in Outlook using OLE:

const
  olMailItem = 0;
var
  Outlook, MailItem: OLEVariant;
begin
  try
    Outlook := GetActiveOleObject('Outlook.Application');
  except
    Outlook := CreateOleObject('Outlook.Application');
  end;

  MailItem := Outlook.CreateItem(olMailItem);
  MailItem.Recipients.Add('mshkolnik@scalabium.com');
  MailItem.Subject := 'your subject';
  MailItem.Body := 'Welcome to my homepage: http://www.scalabium.com';
  MailItem.Attachments.Add('C:\Windows\Win.ini');
  MailItem.Send;
  
  Outlook := Unassigned;
end;

If you want to create a message in html-format, you can use the HTMLBody property instead a Body. But note that this HTMLBody property is available staring from Outlook 98 only.

See also
 
SMExport suite
SMImport suite
SMReport
SMDBGrid
MAPIMail
Paradox Viewer
Paradox ActiveX
ExcelFile Viewer
Metafile Convert
DBLoad
DBExport tools
 
 
Contact to webmaster

 

If you're into technology and you are in the market for a laser printer, then look no longer! Our gadget place has everything you want! Take a gander at a notebook computer along with our lowest prices on hp toner cartridges you can find!


Borland Software Code Gear Scalabium Delphi tips

Copyrightc 1998-2008, Scalabium Software. All rights reserved.
webmaster@scalabium.com

December 6, 1999

SMExport advertising