FoxPro Programming
SMTP attach file containing a comma
Gravatar is a globally recognized avatar based on your email address. SMTP attach file containing a comma
  Robert Jacobs
  All
  Sep 15, 2023 @ 06:51am

Good afternoon Rick

I am using SMTP in the current Internet & Client Tools version. When you AddAttachment("XXXX, YYYY") then SendMail throws a -1 error saying it cannot find the file " YYYY". It would appear the comma is treating the parameter as a file list.

Not sure if there is workaround. Thanks.

Gravatar is a globally recognized avatar based on your email address. re: SMTP attach file containing a comma
  Rick Strahl
  Robert Jacobs
  Oct 5, 2023 @ 08:44am

Ugh, sorry for the delay - I had previously replied but didn't actually send the message. Duh.

IAC, there's no workaround short of stripping out the comma from the file name before sending.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: SMTP attach file containing a comma
  Robert Jacobs
  Rick Strahl
  Oct 5, 2023 @ 09:06am

Thanks for getting back. OK hoping maybe some day you might have a look since AddAttachment is used to add a single file and Windows does allow a comma in the file name. We can strip out the comma if the file is created thru our app but cannot do nothing if the user opens a dialog to select a file previousy created.

Gravatar is a globally recognized avatar based on your email address. re: SMTP attach file containing a comma
  Rick Strahl
  Robert Jacobs
  Oct 5, 2023 @ 09:33am

The problem is that there are only a few characters that Windows doesn't allow for filenames and adding a list as string always needs an exclusion character.

The way to do this right would be to use an AddAttachment() method and create a collection that can be passed up to the .NET component. That would only work with the .NET component though not the classic wwIpstuff mail bits...

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: SMTP attach file containing a comma
  Rick Strahl
  Robert Jacobs
  Oct 5, 2023 @ 10:17am

Actually - ha ha - I'd already done this.

You can use loSmpt.AddAttachment() which directly attaches .NET attachment objects and that should work with , in the filename - as long as the file name is valid it should work.

Note that this only works in .NET mode (.nMailMode = 0) - the old wwIPstuff version continues to use the comma delimited list even when you use this method (ie. it build a string).

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: SMTP attach file containing a comma
  Robert Jacobs
  Rick Strahl
  Oct 10, 2023 @ 09:15am

OK thanks. So .NET mode is the workaround for file name containing a comma when using ADDATTACHMENT(). Actually .NET mode should be the preferred mode so not really a workaround in that sense. Great to know.

Gravatar is a globally recognized avatar based on your email address. re: SMTP attach file containing a comma
  Rick Strahl
  Robert Jacobs
  Oct 10, 2023 @ 02:07pm

Well the documentation has cAttachment removed, although it's still in the file and the recommendation is to use AddAttachment() regardless of whether .NET is used or not (although nMailMode=2 will still fail with ,).

wwSmtp::cAttachment

+++ Rick ---

© 1996-2025