Sending an HTML email using Outlook Express (No Outlook)

We really need this in the knowledge base and I can't seem to find much on google, and anything I do find only hints at an answer and offers no working examples.

I've managed to do this with Oulook (not Outlook Express) but I strictly need Outlook Express.

I'd like a working example if at all possible.

I have BDS 2006 (Delphi 2006)
LVL 13
rfwoolfAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rfwoolfAuthor Commented:
Here an example I found through google that HINTS about doing it but leave me lost:
===USELESS EXAMPLE 1===
http://groups.google.com.au/group/borland.public.delphi.oleautomation/browse_thread/thread/78c65f4bf215a1a5/49d9b742467f3252%2349d9b742467f3252
"A hack that seems to work in both Outlook and OE is add an HTML attachment
and set the message body to nil. Not just an empty string, but nil. The HTML
attachment will be used as the message body."
0
rfwoolfAuthor Commented:
Okay I manged to find a solution..

here is a working example of how to send an email using MAPI which uses the default mail handling program (in many cases Outlook Express - and yes if you're worried that they might be using a different program you should find your own solution to that problem).
http://www.scalabium.com/faq/dct0115.htm

Then here's the part that executes the SendMail function:
procedure TForm1.Button1Click(Sender: TObject);
begin
  SendMail('Re: mailing from Delphi', //Subject
           'Welcome to http://www.scalabium.com'#13#10'Mike Shkolnik', //body
           'c:\autoexec.bat', //attachment
           'your name', 'your@address.com', //sender name, senders address
           'Mike Shkolnik', 'mshkolnik@scalabium.com'); // recipient name, recipient address
end;

Simply set the body to '' (blank -- I can't seem to set it to null or nil)
Set the attachment to your html file
Example:
procedure TForm1.Button1Click(Sender: TObject);
begin
  SendMail('Re: mailing from Delphi',
           '', // Body is blank
           'c:\MyEmail.html', //Your html file
           'your name', 'your@address.com',
           'Mike Shkolnik', 'mshkolnik@scalabium.com');
end;

All you now need to do is generate your html in a Memo or wherever, and use
Memo1.Lines.SaveToFile('c\MyEmail.html');
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.