No announcement yet.

Email Attachments

  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    LOL, thanks guys for all your suggestions and I'm sorry I haven't had a chance to get to it today. As what probably happened to you, Scriptcase crashed on me this morning and I spent what little time I had, working on the fix. Didn't realize all my backups over the year totaled over 20 gig until me trying to zip up the www folder took over an hour and wasn't half way finished! So had to clean it all up and get the fix in place - which worked. I will try to look at my attachment problem some more tomorrow and get more details too. I'm about worn out on this one...

    Thanks again for the suggestions so far! If I wasn't doing this for free, I'd be a bit embarrassed at how long this has taken me... =)



    • #17
      Thanks again guys for your help here. I've tried multiple things again, using the suggestions and now think I must be missing something else. I have tried so many different things and am getting emails but no attachment - any help / suggestion would be much much appreciated!

      I've attached 3 images - one of the MySql database (I assume the image field should be a blob even though we're doing file name), one of Scriptcase Edit Fields (to show you how they're configured), and one of the actual Field (in case there is anything I didn't set correctly in it). The "OnAfterInsert" code looks like this:

      [rptid] = {Rcrdid};

      $mail_message = NULL;

      // Get email settings for sending mail
      sc_lookup(em, "SELECT smtp_server, smtp_user, mail_from, smtp_pwd, mail_to_alert, mail_to_board FROM tbl_mail WHERE type = 'main'");
      [server] = {em[0][0]};
      [user] = {em[0][1]};
      [from] = {em[0][2]};
      [pwd] = {em[0][3]};
      [toalert] = {em[0][4]};
      [board] = {em[0][5]};

      // Get details of new submission
      $check_sql = "SELECT added, name, phone, email, address, whenobserved, description, discussed, image FROM reports WHERE rcrdid = [rptid]";
      sc_lookup(rp, $check_sql);
      [rp_added] = {rp[0][0]};
      [rp_name] = {rp[0][1]};
      [rp_phone] = {rp[0][2]};
      [rp_email] = {rp[0][3]};
      [rp_address] = {rp[0][4]};
      [rp_observed] = {rp[0][5]};
      [rp_descrip] = {rp[0][6]};
      [rp_discuss] = {rp[0][7]};
      [rp_image] = {rp[0][8]};

      // ** Send email notification
      // Email parameters
      $mail_smtp_server = "[server]"; // SMTP server name or IP address
      $mail_smtp_user = "[user]"; // SMTP user name
      $mail_smtp_pass = "[pwd]"; // SMTP password
      $mail_from = "[from]"; // From email
      $mail_to = "[toalert]"; // To email
      $mail_subject = "Attention - New Submission ID: " . [rptid]; // Message subject
      $mail_message = $mail_message.'The following information was just submitted: <br><br>'; // Message body
      $mail_message = $mail_message.'Reported date: ' . date("l, jS \of F Y",strtotime([rp_added])) . '<br>';
      $mail_message = $mail_message."Reporting: " . [rp_name] . "<br>" ;
      $mail_message = $mail_message."Number: " . [rp_phone] . "<br>" ;
      $mail_message = $mail_message."Address: " . [rp_email] . "<br>" ;
      $mail_message = $mail_message."Residence: " . [rp_address] . "<br>" ;
      $mail_message = $mail_message."Observed: " . [rp_observed] . "<br>" ;
      $mail_message = $mail_message."Description: " . [rp_descrip] . "<br><br>" ;
      $mail_message = $mail_message."Discussions (if app): " . [rp_discuss] . "<br><br>" ;
      $mail_message = $mail_message."Thank you," . "<br><br>";
      $mail_message = $mail_message."Alert Team. ";
      $mail_format = 'H'; // Message format: (T)ext or (H)tml
      if (empty([rp_image]))
      $mail_attachments = ' ';
      $mail_attachments = '/home/user/public_html/reports/_lib/file/img/'.[rp_image];

      // Send email";

      Last edited by mslatter; 08-05-2015, 04:40 PM.


      • #18
        ooook... man... i think this is your problem.

        1.- if you are using a blob then you must use the scriptcase "Image(Database)" type of field, if not you are saving the "File name" of the image instead of the actuall image data.. remember when you are using a blob... you are inserting "binary data" into your database, in other words you are including the actual 1 & 0's of your file into the database.

        2.- being that the case.. you need to take such info out of the database and then place it into some directory so it can be attached to the email. to do so.. use something like

        PHP Code:
        3.- once you got the file in place then you use such path to the file to attach it to the email.

        Hope this helps...Regards


        • #19
          Wow....again, kafecadm I really appreciate your help! That is all it was after days and days of testing... I should have indicated the field type first =( I changed the image field type to 'text' and used the same paths I'd been using, and the image is attached to the email.... what a relief after weeks of working on this.

          Thanks again SO much! I owe you....
          Last edited by mslatter; 08-06-2015, 10:03 AM.


          • #20
            No worries that's what we are here for.


            P.D- dude one more thing.. remember that if you use Image File Name in your scriptcase there is no need for you to use the table data as Blob... a varchar(500) <- pick the lenght that suits you better... would be enough. ;D
            Last edited by kafecadm; 08-06-2015, 03:07 PM. Reason: add comment about database field


            • #21
              Originally posted by mslatter View Post
              Thanks again SO much! I owe you....
              We all owe him a lot dude, kafecadm is already listed in the live savers heroes list, he is just too modest to admit it

              I just wanna emphasize again, why would you use the blob thing and store your data in the database... use file name is much easier and better than saving in the database, later on you will have heavy database for nothing.. just my 2 cents



              • #22
                kafecadm is indeed a hero - I PM'd him for his paypal right away and he didn't even reply - that's how modest he is =)

                Yes thanks MikeDE, you're absolutely right. I tried resorting to saving it in the database because I'd tried for weeks (literally) to get the bloody file path right for saving the pictures in another directory and couldn't get it. After your added help, it made me realize that maybe it wasn't the path at all, but something else I was doing wrong....which is why I posted all the details per kafecadm's request and he saw the issue right away.

                All this to say, when I realized what the problem was, I switched back to trying to get the images saved to a directory (verse in the DB)...made the image field 'text' (although kafecadm suggested varchar afterwards) and it works exactly how you want it to....and ultimately how I wanted it to work too, so we're all good! =) I realize I could probably go change the field to 'varchar' but after all the work already, I don't feel like redeploying it again since it's working.

                Thanks again to both of you guys. Lesson learnt on this side, I assure you. They say ignorance is bliss....but in this case, I almost went mad because of it! LOL

                Cheers! TFIF


                • #23
                  Good luck Mslatter. One good thing here is that you learned a lesson and will be quite equipped if a similar issue gets encountered in the future.