daffyduck Posted June 11, 2008 Share Posted June 11, 2008 Can anyone help me with emailing a container field (stored jpg) either as an attachment or in the body of an email ? Any help would be gratefully accepted.smiley-tongue-out Quote Link to comment Share on other sites More sharing options...
AHunter3 Posted June 11, 2008 Share Posted June 11, 2008 by "stored" do you mean "stored as a reference"? Or do you mean "No, I stored the JPEG in the container field, not 'as a reference'" ? If it is stored as a reference, what you actually attach to your email is the original JPEG which is on a hard drive somewhere OUTSIDE of FileMaker, and FileMaker knows where. If not, you have to first export the image FROM the container field to an exterior location such as the Desktop or the Documents folder of the current user and THEN attach the exported file to the email. (Then clean up after yourself if you wish by nuking the exported file so as to not clutter up the user's Desktop/Documents folder) You are on a Mac so any image stored as a reference will return a multiple-line string if you ask for GetAsText (YourTable::YourContainerField), the bottom line of which should start with "imagemac:" You can get the filepath of that image by doing this, therefore: Let ([imagetxt = GetAsText (YourTable::YourContainerField; imagepth = Middle (imagetxt, Position (imagetxt, "imagemac:", 1, 1)+Length ("imagemac:"), Length (imagetxt) )]; Substitute (imageth, "imagemac", "filemac") ) If I did that right (didn't check), that should output something akin to filemac:Macintosh HD/Users/daffyduck/Documents/Pix/My Jpeg for Email.jpg Set a $variable to that string: Set Variable [$Attachment, Let ([imagetxt = GetAsText (YourTable::YourContainerField; imagepth = Middle (imagetxt, Position (imagetxt, "imagemac:", 1, 1)+Length ("imagemac:"), Length (imagetxt) )]; Substitute (imageth, "imagemac", "filemac") )] Now you can email it: Send Mail [To = emailaddy@domain.com; Subject =hello world; Body = YourTable::YourEmailBodyTextField; Attachment = $Attachment] ======= If instead you are NOT storing your JPEGS as references, export then attach the exported doc: Set Variable [$Attachment, Get(DesktopPath) & "/Attachme.jpg"] Export Field Contents [YourTable::ContainerField, $Attachment] Send Mail [To = emailaddy@domain.com; Subject =hello world; Body = YourTable::YourEmailBodyTextField; Attachment = $Attachment] Quote Link to comment Share on other sites More sharing options...
daffyduck Posted June 13, 2008 Author Share Posted June 13, 2008 Hi Ahunter3, Thanks for your quick response - the jpg's are stored in the container field and in a separate file from which the emails are sent. The idea is - I find a set of records from my 'contact' file and then find a record from my 'image' file (with the container field of the jpg and its associated fields - eg title , size , artist) and attach it to the emails I'm sending out through the 'contact' file. Does this change the general formula you sent me ? smiley-tongue-out Quote Link to comment Share on other sites More sharing options...
AHunter3 Posted June 13, 2008 Share Posted June 13, 2008 What do you mean by "find" ? What are the parameters that indicate that a given JPEG in your images file is the image to attach to a given emal? Quote Link to comment Share on other sites More sharing options...
daffyduck Posted June 14, 2008 Author Share Posted June 14, 2008 By 'find' I mean that I will manually select the record in the image file that I wish to attach. smiley-tongue-out Quote Link to comment Share on other sites More sharing options...
AHunter3 Posted June 14, 2008 Share Posted June 14, 2008 Oh! So the image-file record is not in any shape way fashion or form related to the contact record, but you want to send out an email that gets part of its information from the contacts record and part of its information (including the attachment) from the image-file record? Do you have a serial number or other unique identifier in one or the other of those tables? If so, put a global field in the OTHER one, and create a relationship between the global field and the other table's serial number; use that to indicate your selection. For example if your image-file table has serial numbers: [Manual: Do your Find in Contacts for the contact folks you want to send emails to; get the serial number of the image you wish to send and paste it intot the global field you've added to Contacts] Now use the script, but for "YourTable" use Contacts for the data that's in that table and use Images to get the related Images table data including the file path for the attachment. Quote Link to comment Share on other sites More sharing options...
daffyduck Posted June 16, 2008 Author Share Posted June 16, 2008 Hi there, I have been working with your script and your guidance has been invaluable. The script works fine with one problem that I do not seem to be able to solve. The attached image file is created on a separate email instead of the one with all the text data. Any idea why ? smiley-tongue-out Quote Link to comment Share on other sites More sharing options...
daffyduck Posted June 16, 2008 Author Share Posted June 16, 2008 Hi again, The actual problem seems to be that the exported jpg does not attach at all to the intended email when the full script runs. Only the 'text data' is placed in the message part of the intended email. The reason for the two emails is : at the "Export Field Contents [YourTable::ContainerField, $Attachment]" part of your script - one has the option of ticking a box to attach the exported file to an email upon it being saved. Image shows the above option /Users/pauldarcy/Desktop/Picture 2.jpg Hope this can help you help me. Regards smiley-tongue-out Images shows - script debugger and the script /Users/pauldarcy/Desktop/Picture 1.jpg Quote Link to comment Share on other sites More sharing options...
AHunter3 Posted June 17, 2008 Share Posted June 17, 2008 oh! Uncheck that box, you don't want to do that. Sorry, I never use that feature so I forget that it's there. The only outbound email you want to generate is via the later script step Send Mail which will have that file as its attachment if you do it right. Quote Link to comment Share on other sites More sharing options...
daffyduck Posted June 17, 2008 Author Share Posted June 17, 2008 Hi, the script as I have it does not seem to attach the jpg. It must be a small problem because it places all 'text data' and does create the jpg through the 'export field' element fine. It just does not attach the jpg to the email. I would send you a screenshot which shows the script within the script debugger but my posting rules on this site seem to restrict this. smiley-tongue-out Quote Link to comment Share on other sites More sharing options...
AHunter3 Posted June 17, 2008 Share Posted June 17, 2008 I don't need to see your entire script, just the parts of the script where you set up the path to Export Field Contents to and then the Send Mail script step including how you have specified the attachment path. Quick clue: your attachment path for Send Mail should look like this: $AttachmentPath or like this: "Macintosh HD/Users/daffyduck/Documents/ExportedFile.jpg" not like this: "Macintosh HD/Users/daffyduck/Documents/" & YourTable::SomeField Quote Link to comment Share on other sites More sharing options...
daffyduck Posted June 17, 2008 Author Share Posted June 17, 2008 Set Variable[$Attachment; Value:Get(DesktopPath) & "/Attachment.jpg"] Export Field Contents [GALLERY STOCK::Image; "$Attachment"] Send Mail [To: "emailaddress"; Subject: "Painting on show" ; Message: GALLERY STOCK::Titled & " "& GALLERY STOCK::Artist; "$Attachment"] Above is the script at present. It will place the text data into the Subject & Message. It does not attach the jpg in its present state. Hope you can solve it. smiley-tongue-out Quote Link to comment Share on other sites More sharing options...
AHunter3 Posted June 17, 2008 Share Posted June 17, 2008 Rather odd... that looks like it ought to work! Try inserting an indefinite pause between Export Field Contents and Send Mail. (Click Continue manually when it pauses, of course) If that does the trick, then try changing the pause to a 0-second pause. If the first pause works but the second does not, lengthen the pause duration until it catches the file each time you try it. Quote Link to comment Share on other sites More sharing options...
daffyduck Posted June 17, 2008 Author Share Posted June 17, 2008 Tried the pause but now I'm getting a error message from filemaker. - "Attachment.jpg" could not be created on this disk. Use a different name , make more room on disk , unlock it or use a different disk. smiley-tongue-out Quote Link to comment Share on other sites More sharing options...
AHunter3 Posted June 17, 2008 Share Posted June 17, 2008 Are you by any chance running MacOS X 10.5.x "Leopard" ? Quote Link to comment Share on other sites More sharing options...
daffyduck Posted June 18, 2008 Author Share Posted June 18, 2008 No I'm using Tiger. I have sorted it out. I just rewrote the script you gave me and it is working fine now. So thank you very much ! Bye the way do you know if there is any way of defining the 'from' (sender of the email) element of the email sent from Filemaker ? When the email is sent from the Filemaker file it just grabs the last used email account in the Mail programme to send the email. I would like to be able to define a particular account. Look forward to hearing from you. Regards and thanks again. smiley-tongue-out Quote Link to comment Share on other sites More sharing options...
AHunter3 Posted June 18, 2008 Share Posted June 18, 2008 I am unaware of any way for FileMaker to control the "FROM" header (sending account) using Send Mail or Open URL ["mailto:"] which are the two primary ways of sending emails out. AppleScript is a possibility but you'd have to customize it for each and every possible email client (Mail, Thunderbird, Eudora, Entourage, etc). And that's assuming that those email clients are set up to let AppleScript tell them "using account XXXX" which they may or may not be. Quote Link to comment Share on other sites More sharing options...
daffyduck Posted June 18, 2008 Author Share Posted June 18, 2008 I thought it was a long shot - but thanks for the help with the container field. smiley-tongue-out Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.