3

I have made a form that I use to send a mail using Indy. The form can be used to attach files as well. All this is working very fine when I use the sample in the link below and when I use it in a utility I have made for sending invoices made as PDF files from an Excel project.

The strange things begin to happen when I put it to use in a large application I have that uses UniDAC and DevExpress - then all of a sudden my Danish chars in emailbody is gone. The are still present in the subject. I haven't made any changes in the code and the form is executed in the same way as in the sample.

Any ideas as to what I should be looking for in order to get this working?

The sample can be downloaded here: www.hugopedersen.dk/_guest/sendmail.zip (some comments and text might be in Danish, but that should have no influence in how the code works)

Marjan Venema
  • 19,136
  • 6
  • 65
  • 79
OZ8HP
  • 1,443
  • 4
  • 31
  • 61
  • No, comments generally do not affect the execution of the program! – Andreas Rejbrand Jan 29 '12 at 20:57
  • 1
    Code looks fine at first glance and works as you say in an example project. Therefore I'd look for (other/more) difference between the example project and the actual one. Check for uses of `SendMail.` in the actual project that might interfere. Don't think Indy has any issues with global settings that might be overridden by some code in the actual project. Are you using the same Indy version in both your example and actual projects? Are you using a D2009+ version and if so are you doing anything to the SystemDefaultCodePage that could interfere with automatic implicit conversions? etc, etc... – Marjan Venema Jan 29 '12 at 21:01
  • 3
    I am not on a machine right now that can access the .zip file, so without seeing the code or knowing which versions of Delphi and Indy are being used, I can only speculate - assuming you are using Delphi 2009+ and a modern version of Indy, make sure you are setting the `TIdMessage.CharSet` and/or `TIdText.CharSet` properties to a Danish-compatible charset as needed. Indy uses `us-ascii` by default for message bodies unless told otherwise, for compatibility with various protocol specs. Message headers, like `Subject`, on the other hand, use `utf-8` by default under Delphi 2009+. – Remy Lebeau Jan 30 '12 at 05:58
  • My Indy says 10.5.7 and I am using Delphi XE I have no other procedures, functions or properties named SendMail so that should not be a problem. – OZ8HP Jan 30 '12 at 11:48
  • @Marjan Venema yes I am usin the same setup for both samples and the 'big' application (I only have Delphi on this one computer) – OZ8HP Jan 30 '12 at 18:07
  • I'd go with @RemyLebeau-TeamB's comment then, though it remains a mystery to me why behaviour would be different in your big app versus the example. – Marjan Venema Jan 30 '12 at 19:24
  • Under D2009+, you definately need to make use of the various `CharSet` properties, since Delphi's `String` type is Unicode now, so Indy needs to know what character encoding to convert the Unicode data to. That wasn't as big a requirement in pre-D2009 versions (in fact, earlier versions of Indy didn't even process the `CharSet` properties and just transmitted `AnsiString` encoded data as-is. – Remy Lebeau Jan 31 '12 at 20:39

0 Answers0