Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How can I create a new message in MS Outlook using OLE? Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
09-Jun-03
Category
OLE
Language
Delphi 2.x
Views
168
User Rating
10
# Votes
1
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Mike Shkolnik

How can I create a new message in MS Outlook using OLE?

Answer:

1   const
2     olMailItem = 0;
3   var
4     Outlook: OLEVariant;
5     MailItem: Variant;
6   begin
7     try
8       Outlook := GetActiveOleObject('Outlook.Application');
9     except
10      Outlook := CreateOleObject('Outlook.Application');
11    end;
12  
13    MailItem := Outlook.CreateItem(olMailItem);
14    MailItem.Recipients.Add('mshkolnik@scalabium.com');
15    MailItem.Subject := 'your subject';
16    MailItem.Body := 'Welcome to my homepage: http://www.scalabium.com';
17    MailItem.Attachments.Add('C:\Windows\Win.ini');
18    MailItem.Send;
19  
20    Oulook := Unassigned;
21  end;


I can save tasks and contacts to Outlook using OLE, but I need to be able to 
synchronize existing contacts. Do you have any ideas?

I think that you have a two methods with solutions 

1. 

22  var
23    app, NameSpace, Contact: OLEVariant;
24  begin
25    app := CreateOleObject(`Outlook.Application`);
26    NameSpace := app.GetNameSpace(`MAPI`);
27    Contact := NameSpace.GetItemFromID(EntryIDItem, EntryIDStore)
28      {...}
29  end;


2. also you can navigate by contract items and compare the IDs. I understood that 
it`s not a good solution but without errors:) 

30  app := CreateOleObject(`Outlook.Application`);
31  Contacts := app.GetDefaultFolder(10); {olFolderContacts}
32  for i := 0 to Items.Count - 1 do
33  begin
34    Contact := Items[i];
35    {...}
36  end;


How can I format the content of the body text to be HTML? 

If you want to have html formatted message, use HTMLBody property instead Body. But 
not that this property is available starting from Outlook 98 only. 

I need to parse through a certain folder's messages and put some data into a 
database based off what is in the  messages.  Suggestions? 

Check my articles about MS Outlook programming: 

http://www.scalabium.com/faq/dct0120.htm
http://www.scalabium.com/faq/dct0121.htm
http://www.scalabium.com/faq/dct0123.htm
and download a Delphi sample for these articles: 
http://www.scalabium.com/faq/delphioutlook.zip

I try to execute this procedure in my program, i get the following error: project 
project1 raised exception class EOleSysError with message 'CoInitialize not 
called'. 

You must call the OLEInitialize(nil) procedure from ComCtrls.pas unit. Some third-party suites unload this library from memory. Also additioanlly you must call it from every your thread if you'll use an OLE from this thread. 

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC