Scalabium Software |
|
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: 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.
|
|
Copyright© 1998-2024, Scalabium
Software. All rights reserved. |