Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDO2000 attachments

Status
Not open for further replies.

colfrank

Programmer
Jun 26, 2014
9
US
Got to have a mind block here
Error.. cannot find the last file.. but it is there... is there another syntax for multiple file attachments?

.cAttachment = "C:\onedrive\GHSAdata\dispatcher\flights.dbf, ;
C:\onedrive\GHSAdata\dispatcher\flights.cdx, ;
C:\onedrive\GHSAdata\dispatcher\freeform.dbf"

If I remove the third one, it cannot find the second file....
 
You need to give us a lot more information. What exactly are you doing here? What object have you instantiated? To what does cAttachment belong?

From the title of your thread, I will assume you are using the CDO.Message object. If so, then you need to call the AddAttachment method repeatedly for each attachment. Something like this:

Code:
loMessage = CREATEOBJECT("CDO.Message")
WITH loMessage
  .To = "some person"
  .Subject = "whatever"
  .TextBody = "something"

  .AddAttachment("flights.dbf")
  .AddAttachment("flights.cdx")
  .AddAttachment("freefrom.dbf")

  .Send
ENDWITH

If that doesn't fit in with your scenario, then please clarify what you are doing.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Why not add them one by one with AddAttachment(cFile). Called in a loop?

I only found these VFP specific property names when a cdo2000.fxp is used, this likely is based on CDO, but is a wrapper around it, so maybe something is wrong with your version of it and it wrongly splits the cAttachment used to add them with the native CDO AddAttachment method. You should have the cdo2000.prg code to be able to debug this behavior, or is it only provided as fxp object code without debug info?

There are so many ways to mail and cdo2000 or CDO in general so often depends on a company having an exchange server running so Outlook is installed with CDO extension at all. I'd rather use either outlook.application automation or make use of Craig Boyds extended Mapi FLL:
Bye, Olaf.

Olaf Doschke Software Engineering
 
Seems that my version of CDO2000 does not like Path statements... this works fine with the files in the same directory.

LOCAL lcFiles
SET SAFETY off
COPY FILE C:\onedrive\GHSAdata\dispatcher\flights.dbf to flights.dbf
COPY FILE C:\onedrive\GHSAdata\dispatcher\flights.cdx to flights.cdx
COPY FILE C:\onedrive\GHSAdata\dispatcher\freeform.dbf to freeform.dbf
SET SAFETY ON
lcFiles = "flights.dbf,flights.cdx,freeform.dbf"

loMail = NEWOBJECT("Cdo2000", "Cdo2000.fxp")

WITH loMail


* Attachments are optional
.cAttachment = lcFiles

 
I found on version of cdo2000 at
This is using CDO.Configuation and CDO.Message and you could simply switch to using AddAttachment yourself.

WITH This.oMsg

cAttachment processing is using this loop:
Code:
* Process attachments
IF NOT EMPTY(This.cAttachment)
* Accepts comma or semicolon
* VFP 7.0 and later
*FOR lnind=1 TO ALINES(laList, This.cAttachment, [,], [;])
* VFP 6.0 and later compatible
FOR lnind=1 TO ALINES(laList, CHRTRAN(This.cAttachment, [,;], CHR(13) + CHR(13)))
lcAttachment = ALLTRIM(laList[lnind])
* Ignore empty values
IF EMPTY(laList[lnind])
LOOP
ENDIF

* Make sure that attachment exists
IF ADIR(laDummy, lcAttachment) = 0
This.AddError("ERROR: Attacment not Found - " + lcAttachment)
ELSE
* The full path is required.
IF UPPER(lcAttachment) <> UPPER(FULLPATH(lcAttachment))
lcAttachment = FULLPATH(lcAttachment)
ENDIF
.AddAttachment(lcAttachment)
ENDIF
ENDFOR
ENDIF

If I let this run a littel modified just to see how the names are extracted, that's working fine:
Code:
Local lcAttachments

lcAttachment = "C:\onedrive\GHSAdata\dispatcher\flights.dbf, ;
C:\onedrive\GHSAdata\dispatcher\flights.cdx, ;
C:\onedrive\GHSAdata\dispatcher\freeform.dbf"

*   lcAttachments = "D:\temp\defect.dbf, ;
*   D:\temp\defect.cdx, ;
*   D:\temp\defect.fpt"

For lnind=1 To Alines(laList, Chrtran(lcAttachments, [,;], Chr(13) + Chr(13)))
   lcAttachment = Alltrim(laList[lnind])
   * Ignore empty values
   If Empty(laList[lnind])
      Loop
   Endif

   * Make sure that attachment exists
   If Adir(laDummy, lcAttachment) = 0
      ? "ERROR: Attacment not Found - " + lcAttachment
   Else
      * The full path is required.
      If Upper(lcAttachment) <> Upper(Fullpath(lcAttachment))
         lcAttachment = Fullpath(lcAttachment)
      Endif
      ? lcAttachment
   Endif
Endfor

As I don't have any of your files I get three ERROR lines printed, but the file names are as in your setting, including paths. And with example files I do have, this is working out. You might have another cdo2000.fxp version, no idea what happens in your case, but if you shorten names to just filename the FULLPATH() function comes into play. No idea why that would help.

As you don't show your cdo2000 code or tell your VFP version it's hard to tell what exactly is going wrong.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Thanks guys for all the input
My working solution may not be the best.... but being 80 years old I will stay with it before I screw it up.
BTW VFP 9 SP2
 
Well,

if you're not interested to see into details of code you haven't written, if I were you I'd at least look out for a later cdo2000.prg, because your's seems to be a broken version in that aspect and maybe also buggy in other aspects.

Bye, Olaf.

Olaf Doschke Software Engineering
 
I don't know if that's the newest version. I imagined you knew where you originally got this from and would look there for the latest version.

Bye, Olaf.



Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top