For some reason I have recently experienced a peculiar error which I cannot figure out. I am attaching a file to an email message and here is the code.

	TFileName fileToSend;
  • If I run in debug mode on hardware and insert a break point before adding the attachment it will work (as long as I single step a couple of instructions first - never if I immediately press play)
  • If I run in debug mode on hardware without the breakpoint iStatus returns error code -28 (invalid filename format).
  • If I run in normal mode on hardware iStatus returns error code -4 (not enough memory).

Can anyone understand what is happening here? I have attempted to restore code to previous working state but to no avail so I cannot figure out what has effected this problem.

Thanks for the help.