Anyone know of a good example of generating HTML e-mail with embedded images and an alternate text part? I need to generate some tabular reports in HTML and would like to embed logos and other images.
I believe Indy can do this with some work, but I was hoping someone could point me to a good example as a starting point. I am open to using libraries other than Indy and commercial solutions provided source is available. Quality and time to implement is more important than cost. The solution also needs to support SMTP based delivery to a mail exchanger.
The other item on my wish list is to be able to leverage FastReports, TRichView or similar tool to generate the HTML message content. There are HTML output filters available for both, but I have not had the opportunity to do any testing. Any feedback on this subject would be appreciated.
Thanks in advance!
David
Read the following articles on Indy's website, they explain the proper way to populate a TIdMesaage for HTML:
HTML Messages
New HTML Message Builder class
These days I use Clever Component's email client, though not free.
The TurboPower Internet (OpenSource) controls worked great for me in the past.
function data64(const filename:string): ansistring;
// uses Classes, IdGlobalProtocols, EncdDecd;
const
crlf = #13#10;
begin
result := '';
with TIdMimeTable.Create do
try
result := 'data:'
+ GetFileMIMEType(filename) + ';';
finally
Free;
end;
with TMemoryStream.Create do
try
LoadFromFile(filename);
result := result + 'base64,' + crlf
+ EncodeBase64(Memory,Size);
finally
Free;
end;
end;
We tried this years ago with Indy and embedded cid: images like this:
https://forums.codegear.com/thread.jspa?threadID=17473
We never got it stable, each time there was another mail reader that barfed (if we got it working in Outlook, then Thunderbird didn't accept it, or Outlook Express, or, etc, etc).
In the end we did it with .NET using AspNetEmail and it worked like a charm.
--jeroen
It all depends on how many different remote mail clients you have to be able to support. I believe that the well-known Delphi libraries which support SMTP/Mime will do a reasonable job, but they may leave you with support problems when one of your mail users finds that their recipient cannot see a properly formatted e-mail.
I recommend visiting Jacob Palme's site which will give you an idea of some of the problems that you may encounter. It is a little out-of-date, perhaps, but in summary, however you build and send your complex MIME e-mail, you will encounter one or more mail clients which cannot handle the syntax properly. The site also has links to some useful examples of constructions which you can examine and test.
I do not mean to imply that you have to roll your own logic as we did: a good packaged solution will probably be successful in the great majority of cases. We wrote our own Delphi code to handle this some years ago, so I will leave it for others to give you up-to-date information about what is on the shelf now.
Related
What free Delphi component can you recommend for reading an email and an attachment?
I mean reading an email from pop3 server.
I use Delphi 7.
Thank you.
I'd start by trying Indy's TIdPop3 component. I think it's shipped as standard with most Delphi versions.
Try Synapse from Lukas Gebauer. Actually it's not a component, it's just a set of units, which you simply add to your uses list. It's simple, stable and verified by many users.
Check these links ...
Synapse - download pageSynapse - tutorials pageSynapse - POP3 simple example
I have an issue here where we need to control outlook from Embarcadero Delphi 2010.
we used today some thirdparty components for opening the mail sending window, this worked some timeago. but now it seem to fail on newer outlook versions.
are there any component out there dedicated to controlling outlook from Delphi, or are there any MAPI clients that can work as a better replacement for this.
what we need to do basically is to:
1. Start new message in outlook (sending recipient as parameter)
2. receive the sent message so we can store it
3. drag and drop messages from outlook to our application.
if the enduser do not use outlook, a normal MAPI would suffice as replacement.
where do I find a good robust component for doing such job for me ?
For the first two steps regular OLE automation using the Outlook2000.pas unit that comes bundled with Delphi should work fine though you might want to take a look at Dmitry Streblechenko's Redemption library: http://dimastr.com/redemption/ which simplifies many of the more low-level (Extended-)MAPI tasks significantly.
For intercepting the sent message you should create an instance of TItems and connect it to the folder reference you could get from OutlookApplication.Session.GetDefaultFolder(olFolderSentMail). You can then assign an event handler to its OnItemAdd event.
For drag & drop from Outlook into your application you can take a look at Anders Melanders excellent (and free) Drag&Drop library (includes examples for interacting with Outlook): http://melander.dk/delphi/dragdrop/
I've used these components a long time ago and they were fantastic
http://www.add-in-express.com/add-in-delphi/
Here are some features for Outlook
http://www.add-in-express.com/add-in-delphi/programming-outlook.php
I'm wondering if it is possible to display topics from a CHM help file in a form of my Delphi application? I know how to use the htmlhelp api but it launches the external help viewer. I would like to display the help topics within a form
Not tested, but...
If you pass the help url (like ms-help://embarcadero.rs2009/delphivclwin32/System__TDateTime__-#TDateTime_#const.html) to an embedded WebBrowser, it should work.
Another solution in case you don't want to use MSIE, could be to port the chm reader library from Free Pascal. It is written in the Delphi dialect, and should be fairly easily, and allows you to extract HTMLs from the CHM (and compress back if necesary) without additional external dlls.
So like many online companies, we send e-mail advertisements. Outlook 2007 has some quirky HTML rules so things that look fine in any browser, when sent to Outlook 2007, look horrific.
Is there a program where I can preview what the HTML would look like in Outlook 2007?
You are not alone ;-) What I do is try sending the email to me (alone) and then see how it comes out. AFAIK there are no software which can show you the preview ;-)
Edit: Check this question which some useful which you use while sending HTML emails.
I faced the same issue because of the switch from IE to Word as the rendering engine in Outlook 2007.
So I have been using Word 2007 to preview the HTML file to see how it looks, before sending it to Outlook. It has so far worked fine in my case. Try it and let us know if it works for all your cases.
Hello sendning Mass Mails throw Outlook isnt a good idea.
There are Many Opensource Massmailer Try http://sourceforge.net/projects/tellmatic/
And a preview option isnt aviable for html files nor other things in outlook no matter which version 2003 or 2007 or 2010.
Ive had exactly this same issue.
What i had to do is download outlook 2007 to sort this out, and then created a program to send myself emails to test.
Alternatively you can use this site to send emails to any email address:
http://ctrlq.org/html-mail/
Old thread i know, but i think my answer can help anyone that stumbles across this question much as i did.
I am unlucky to be in charge of maintaining some old Yahoo! Store built using their RTML-based platform.
Recently I've noticed that HTML code generated by some RTML functions is sprinkled all over with "padding images" (or whatever is the conventional name for those 1x1 pixel images used to enforce layout). I have nothing against using such images, but... all those images are supplied with an ALT attribute like this:
<img href="http://.../image1x1.gif" alt="pad">
With all due respect to the original authors of RTML, but they must have been smoking something when they came up with this "accessibility enhancement"... :-(
Anyway, here are my questions:
Does anybody know a list of all RTML functions that generate HTML with all these "pad" images?
Is there any way to get rid of all those alt="pad" attributes without rewriting a lot of RTML code?
NB: This may sound a little cynical, but improved accessibility is not the main goal here. The main goal is to stop exposing those moronic alt="pad" attributes to Google and other smart search engines. So client-side scripting is not going to help, as far as I know.
Thank you!
P.S. Probably, most of you are really lucky and never heard of RTML. Because if somebody would establish a prize for software products based on
commercial success
------------------
usability
ratio, this RTML-based "platform" would probably win the first place.
P.P.S. Apparently someone from Yahoo! finally listened, because I can no longer find those silly "pad" tags in the RTML generated for our store. Nevertheless, one of the ideas offered in response to my original question does provide a very practical solution - not just to the original problem but to any similar problem with RTML platform. See the winning answer - it's really good.
The only way I see is to have your own website front-end that will filter whatever you want from the RTML site....
for example, your rtml site is at http://rtmlusglysite.yahoo.com/store/XYZ01134 , you could host a simple PHP front-end at http:://www.example.com that would be acting like a "filtering" HTTP web proxy, so http://rtmlusglysite.yahoo.com/store/XYZ01134/item1234.rtml would be accessed by http://www.example.com/item1234.html
It's not an ideal solution, but it should work, and you could do some more fancy stuff.
Nice try from the other posters, but there is a very simple RTML command that will do it. . .
TEXT PAT-SUBST s GRAB
MULTI
HEAD
BODY
TEXT #var-with-alt-tag-equals-pad-in-it
frompat "alt=\"pad\""
topat ""
The above RTML will find all instances of alt="pad" and replace it with nothing.
Well you're right on RTML being relatively untraveled :)
Do you have a way to add your own attributes to these images tags? If so, would it be possible to override the alt attribute? If you specify alt="", I would think that would override Yahoo's... Otherwise consider putting a useful alt tag in there for the blind and dialup types.
It's the first time I'm hearing about this platform, but here is an idea: if you can add javascript to the pages, you could write a function that will run after the page has loaded and remove all the alt="pad" attributes from the page.
Unfortunately this solutions works only with browsers that know about scripting, so lynx or some other text based browsers might not support it.
I have shared a link official RTML guide from yahoo. Hope it will help. Thanks!
List of available RTML books and resources