close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Adding attachments from recordset - need to specify folder

Thread began 11/15/2018 5:42 am by georgina_barrett_187762 | Last modified 11/20/2018 7:42 am by Ray Borduin | 81 views | 9 replies |

georgina_barrett_187762

Adding attachments from recordset - need to specify folder

Using the new MySQLi Send Email. I have successfully added 2 attachments from the entered value section. The problem I have is that I also need to select multiple values from a recordset. I have done this (see code below) however as with the other attachments I need to specify the folder that they are stored in (../clientconf/). I can add it with the entered value attachments but not with the recordset loop

$Email->addAttachment("../clientconf/".($Payments->getColumnVal("ATOLCert")) ."");
$Email->addAttachment("../clientconf/".($Service1->getColumnVal("UploadConf")) ."");
$Email->addAttachmentFromRS("service","UploadConf");

Sign in to reply to this post

Ray BorduinWebAssist

You would probably have to either manually add a loop for the recordset and use addAttachment(), or you could append the folder name to the column in the Recordset SQL statement like:

SELECT *, CONCAT('../clientconf/',UploadConf) AS Attachment FROM table

Sign in to reply to this post

georgina_barrett_187762

Oh thank you - I will use the CONCAT method

Sign in to reply to this post

georgina_barrett_187762

I have set everything up ok (or so i thought) and the email is sending however there are no attachments. Neither the entered value attachment or the repeat region attachments are sending. I have echoed the values to the page so i know there are values in there. I have tried putting absolute and relative urls.

<?php
if (isset($_POST["submit"]) || isset($_POST["submit_x"])) { //WA Universal Email
$Email = new WA_Email("waue_email_conf_2");
$Email->Redirect = "request_Detail.php?ID=".((isset($_POST["RequestID"]))?$_POST["RequestID"]:"") ."";
$Email->From = "info@website.co.uk";
$Email->BurstSize = "200";
$Email->BurstTime = "1";
$Email->WaitTime = "1";
$Email->addTo("".((isset($_POST["Email"]))?$_POST["Email"]:"") ."");
$Email->addCC("".((isset($_POST["Email2"]))?$_POST["Email2"]:"") ."");
$Email->addAttachment("https://www.website.co.uk/clientconf/".($Payments->getColumnVal("ATOLCert")) ."");
$Email->addAttachmentFromRS("service","Attachment");
$Email->BodyFile = "../webassist/email/waue_email_conf_2_body.php";
if (function_exists("rel2abs") && $Email->Redirect) $Email->Redirect = $Email->Redirect?rel2abs($Email->Redirect,dirname(__FILE__)):"";
for ($emailGroup=0; $emailGroup<sizeof($Email->To); $emailGroup++) {
$Email->Subject = "".($request->getColumnVal("Title")) ." ".($request->getColumnVal("Surname")) .", ".($request->getColumnVal("Product")) ." ".($request->getColumnVal("ClientID")) ."";
$Email->send($emailGroup);
}
$Email->close();
}
?>

Sign in to reply to this post

Ray BorduinWebAssist

The paths should be relative. http:// paths won't work for adding attachments.

If you can give me FTP access and a URL to reproduce the problem I can debug it and figure out why the attachments aren't sending.

Sign in to reply to this post

georgina_barrett_187762

Thank you, I have made the paths relative and managed to send an attachment by removing the recordset attachment. I think the problem I was having before was if the recordset is empty (or if there is a value in the recordset but there isn't an attachment on the entered value.)

Is there a way to say send attachment only if there is an attachment? I would need this on both the entered value attachments and the recordset value attachments.

Sign in to reply to this post

Ray BorduinWebAssist

You want to not send the email if there are no attachments?

That would probably require some hand coding. If you attach a copy of your page I can try adding it for you and send it back.

Sign in to reply to this post

georgina_barrett_187762

Thank you, no I still want to send the email even if there isn't an attachment. There are 2 types of attachments that get sent with the email. One that is populated from an entered value and the other(s) that come from a recordset. When I tested it before, if there isn't a value for both of these the other attachment doesn't send.

Sign in to reply to this post

Ray BorduinWebAssist

It should detect when the attachment doesn't exist. I've made a small tweak to the WA_Email.php file.... upload the one I have attached and see if that helps.

Attached Files
WA_Email.php
Sign in to reply to this post

georgina_barrett_187762

That works - thanks

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...