whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

28 Visitors Online


 
...send an e-mail through Outlook?
Autor: Thomas Stutz
[ Print tip ]  

Tip Rating (14):  
     


uses
  
ComObj;

procedure TForm1.Button16Click(Sender: TObject);
const
  
olMailItem = 0;
  olByValue = 1;
var
  
OutlookApp, MailItem, MyAttachments: OLEVariant;
begin
  try
    
OutlookApp := GetActiveOleObject('Outlook.Application');
  except
    
OutlookApp := CreateOleObject('Outlook.Application');
  end;
  try
    
MailItem := OutlookApp.CreateItem(olMailItem);
    MailItem.Recipients.Add('YourMailAddress@something.com');
    MailItem.Subject := 'Your Subject';
    MailItem.Body    := 'Your Message';
    myAttachments    := MailItem.Attachments;
    myAttachments.Add('C:\SomeFile.txt', olByValue, 1, 'Name of Attachment');
    MailItem.Send;
  finally
    
myAttachments := VarNull;
    OutlookApp    := VarNull;
  end;
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners