Cardbox Talk


CardboxForumsCardbox Talk > "E-mailing a Non image File using a SMTP server."

E-mailing a Non image File using a SMTP server.

When I attach a Non image file to my e-mail Macro it is received as a JPG attachment

Posted By Post

Jelly Belly

15-Nov-2009 18:13

I have written a (SMTP) E-mail Macro and need to be able to attach a PDF document stored as a Non image document in a image field. I have used the example which successfully attaches the contents of the field ("TECH_NOTE1") to the e-mail but it is received as a JPG attachment.

Dim img
For Each img In ActiveRecord.Images
sender.AttachImage img

How can I attach the PDF from this field and retain the correct file extension? Any help or examples would be most welcome.
NB: I am using the latest version of Cardbox.
Many Thanks


15-Nov-2009 20:22

I think you have to write each pdf first to disk (in a temp folder or so).
You can use the original filename then (obj.OriginalFilename).
Add the just written file from temp as attachment.
(in Help example (sender.AttachFile("c:\path\filename.typ")

Charles Welling

15-Nov-2009 20:24

According to the Help file, AttachImage automatically converts to GIF or JPG, and that's exactly what happens here.

An option would be to copy the file to disk first, but I haven't been able to find a way to do that with a macro. I think this might be an omission in the Non-image feature.
I think you'd better send Cardboss an e-mail.


15-Nov-2009 21:21

Not an omission: simply use b.e.
    set img = images(1)
    img.WriteToFile path+filename


Charles Welling

16-Nov-2009 09:54

Bert, you're absolutely right. I believe I'm one of those rare people who actually read manuals. The manual on WritetoFile hasn't yet been revised and it deals only with writing images. No mention of non-image files. Hence my remark.

The solution of writing the file to disk works, but it would certainly be more elegant if it were possible to attach the files the same way you can attach images.

© 2010 Cardbox Software Limited   Home