PDA

View Full Version : Universal Email v.3.04 - File Attachments


tom92909
04-30-2009, 12:37 PM
I have checked most if not all of the support documents, and looked for any reference here on the forums, but I haven't been able to location any examples of how to include file attachments using Universal Email.

I found this reference and similar on your site and in the help documentation:
Universal Email can send attachments along with the email messages, as long as the file exists on the server. To do this you will only need to specify the file name and location on the server within the attachment tab in Universal Email.

That being said, I am unable to include my attachements with my emails...

My example...

/PDF/<?php echo $row_Recordset1['filename']; ?>

This hasn't worked. Please clarify the Absolute Path.

Thank you in advance for your time and comments.

Ray Borduin
04-30-2009, 12:49 PM
use:

<?php echo(realpath("/PDF/".$row_Recordset1['filename'])); ?>

tom92909
04-30-2009, 01:21 PM
Same result, the message is being sent no problem, but I'm getting no physical file attachment.

I also got a Dialog from CS3..

"It appears that one of your server-side values is improperly coded. Please check this interface for inconsistencies."

This appeared after I added the
<?php echo(realpath("../PDF/".$row_Recordset1['filename'])); ?>

To the Entered Value field in the Attachments Tab for UE.

Ray Borduin
04-30-2009, 02:30 PM
It looks correct. What does it look like in the resulting email include file that references the attachment? Maybe you left some code behind causing the error. It is hard to say without looking at the code.

tom92909
04-30-2009, 02:40 PM
I added just the true absolute path in place of the (realpath("/PDF/".$row_Recordset1['filename']) option that your mentioned. I am still getting the same results either way, but the dialog box is no longer showing up after I made the last change.

Below is the requested code I think...

if ($RecipientEmail) {
$WA_MailObject = WAUE_AddRecipient($WA_MailObject,$RecipientEmail);
}
else {
//To Entries
}

//Attachment Entries
$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"/home/abcdefg/public_html/PDF/".$row_getRecordset1['filename']."");

Ray Borduin
04-30-2009, 02:53 PM
//Attachment Entries
$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"/home/abcdefg/public_html/PDF/".$row_getRecordset1['filename']."");


should be:


//Attachment Entries
$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"". realpath('/home/abcdefg/public_html/PDF/'.$row_getRecordset1['filename']) . "");

tom92909
04-30-2009, 03:15 PM
Using your suggested change just now, I get no errors, but no attachment either.

Ray Borduin
04-30-2009, 03:17 PM
Is the email code below the Recordset?

Maybe add code before that line like:

//Attachment Entries
die(realpath('/home/abcdefg/public_html/PDF/'.$row_getRecordset1['filename']));

That will stop processing the code and write the value to the page. Does the path look correct when you do that?

tom92909
04-30-2009, 03:39 PM
Yes.
The path is perfect using the die command.

So it appears that the Recordset isn't being passed to the path.
I still don't have an attachment either.

tom92909
04-30-2009, 05:33 PM
I have the issue resolved now.

Thank you for your guidance and patience.

Ray Borduin
05-01-2009, 06:33 AM
What was it? Anything you could share to help others that may run into the same problem?

tom92909
05-01-2009, 07:27 AM
Sure.
Part of the problem was that I wasn't sending the filename to the next page with an actual $_POST in my form. So the script that was expecting to get the filename was getting nothing.

The other part of the problem was the Absolute Path issue, that you were so helpful with.

The file is being located just fine and is included in the message.
I do have one last issue that I didn't notice until after I made my last post to this thread.

The attachment file is a PDF file. The attachment isn't being treated as an attachment. It's more like part of the message body. I can extract it from the message and save it to my desktop and it's fine, but if I try to look at it in Outlook there is a bunch of code being dumped into the message body.

Outlook doesn't see the attachment as being an attachment. There is no paperclip icon being displayed either. This is true as well in my gmail account. No paperclip icons in either email client.

Any suggestions?

tom92909
05-01-2009, 10:59 AM
A final update.

Back around the 1st week in December I got a message that Universal Email had been updated. The following is what I received...

Universal Email 3.0.5 addresses the following issues and adds the following functionality:

- Updated for use with Dreamweaver CS4.

- Memento Panel added.

- New preferences interface added at Edit > WebAssist Preferences

- Removed ‘Mail for Windows’ and ‘Mail for Linux’ mail object objects and replaced them with ‘Mail’. This mail object will work properly in either environment if the server is properly configured.

- PDF version of Help documentation now available.

After looking over the notes, I decided that this little patch wasn't really worth my time to upgrade right away. I wasn't having problems with any of my pages that utilized UE v.3.0.4.

Ok the problem that I've been having relates to attachments being included in the message body instead as true attachments.

I upgraded today to v.3.0.5.

The problem has been resolved. My application works brilliantly and I'm truly thrilled with the results.

Outstanding Extension! Thank you WebAssist for your efforts and your products.

pistartech366237
05-02-2009, 10:11 AM
Dear Ray,

I've read the post and tried to implement it to my code, however, it didn't help...
I'm having the same problem. The scenario is the following:
There is the form on the site where the user fills out the information and uploads the example file. The results of this form are sent to admin. I've used Digital File Pro to set up the upload field. The images are being uploaded to the following directory:
public_html/mydomainname/Uploaded_Examples

The email comes to Administrator but without the attachment...

I've binded the upload field to the "Server File Name" with /Uploaded_Examples/ in front - same result - the rest of the fields in the form are being sent except for an attachments.

Please advise.

Best regards,

Paul.

Ray Borduin
05-05-2009, 09:58 AM
Make sure your upload code appears before your email code.

Make sure that you use realpath() when referring to the file path in universal email.

That should be all there would be to it. From there you would need to debug.

kenp276561
05-08-2009, 05:23 PM
I ran into a similar problem and got it resolved through WebAssist by using:

'Attachment Entries
If rsEmails.Fields.Item("attachment1").Value <> "" OR rsEmails.Fields.Item("attachment1").Value <> NULL Then
set WA_MailObject = WAUE_AddAttachment(WA_MailObject,Server.MapPath("attachments/" & cStr((rsEmails.Fields.Item("attachment1").Value)) & ""))
End IF

A recordset field called attachment1 call the image from a folder called attachments.

neileisen207079
05-28-2009, 03:32 PM
I tried the following, after having tried EVERY conceivable path, including even using an actual file name instead of the variable, and nothing worked.

//Attachment Entries
$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"".(realpath("/client_art/".$row_orders['client_art'])) ."");

I finally found this post and tried the above but it doesnt work either.

This is for an image file, and I used the image in the body of the email, which works. I tried that path for the attachment, but it wouldnt work.

When I tried to add the "die" command, nothing at all appeared on the page. Just blank.

Ray Borduin
05-28-2009, 03:36 PM
What version of Universal Email are you using? What email object. using realpath() is usually the trick that works. It has to be a full absolute drive relative path. Relative and even site relative won't work, which is why realpath() is usually the cure.

neileisen207079
05-28-2009, 04:24 PM
Its version 3.0.2
On another page it works using this:
//Attachment Entries
$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"client_art/".((isset($_POST["clientFileName"]))?$_POST["clientFileName"]:"") ."");

On this page I'm just getting the file name from a different place. Of course I tried a variation of this but it didnt work.

Ray Borduin
05-29-2009, 07:13 AM
Add some debug code:

$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"".(realpath("/client_art/".$row_orders['client_art'])) ."");

echo(realpath("/client_art/".$row_orders['client_art']));
echo("<BR>");
die("found file: ".file_exists("/client_art/".$row_orders['client_art']));

That should allow you to see if the path is correct and if it appears the file exists.

neileisen207079
05-29-2009, 07:59 AM
Ray,
Thanks.
That debug code showed that it was not finding the file. I changed it to the relative path using the following code:

$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"".(realpath("../client_art/".$row_orders['client_art'])) ."");

So... I used ../client_art instead of /client_art and it worked! I'm pretty sure I tried that variation yesterday... but probably not with the exact code you gave me - using the realpath syntax. Thank you very much, and hopefully this will help someone else.

Just a suggestion... the realpath code is not mentioned in the help file for attachments in Universal e-mail documentation, and it looks like it should be. Again, thanks.

neileisen207079
06-03-2009, 01:58 PM
Ray, I'm stuck again. I'm trying to send an attachment of an image named
entered value.jpg The entered value is from a field called OrderID

I have this code but its not working:

$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"".(realpath("../client_art/".$_POST["orderID"].jpg)) ."");

There is a file in the client_art folder named to correspond with the entered value of the OrderID, plus the file extension of .jpg.

I cant get it to work.

Ray Borduin
06-03-2009, 04:06 PM
Try:

$WA_MailObject = WAUE_AddAttachment($WA_MailObject,"".(realpath("../client_art/".$_POST["orderID"].".jpg")) ."");

neileisen207079
06-03-2009, 04:54 PM
Thanks Ray. I was so close.... yet so wrong! It worked great. Once again. THANK YOU! I see what I did wrong. I think I already asked this... but how come attachments dont work automatically using the extension? Also wondering why this isnt documented. Is there a plan for an upgrade?

Ray Borduin
06-04-2009, 08:03 AM
Attachments do work automatically. It is just that you need to use a full path to the file.

I will bring it to the attention of the documentation team that the use of the realpath() function to allow relative file paths in php should be more prevalent.

There is no immediate plan for an update of Universal Email, but the next upgrade will be PHP only, so it is likely we might try to address issues like this.

neileisen207079
06-04-2009, 08:16 AM
So, if I used that debug code you gave us in one of the previous posts in this thread to determine the actual full path, and then substituted that I wouldnt need to use realpath and it would work? Even with a variable from a recordset as the filename as in my example here?

Ray Borduin
06-04-2009, 10:22 AM
That is correct.