Adding Attachments with JMail

This is a discussion on "Adding Attachments with JMail" within the Classic ASP section. This forum, and the thread "Adding Attachments with JMail are both part of the Program Your Website category.



 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1  
Old May 5th, 2006, 16:15
New Member
Join Date: Apr 2006
Location: ILLINOIS
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Adding Attachments with JMail

Okay,

Here’s the problem. I’m creating an application that uses JMail to send email. And it works great!! as longs as I don’t try to add an attachment. However, I really need to have my users be able to add attachments; otherwise the purpose of this application is null and void.

I know that the file that is attached needs to be uploaded to a file share folder via FTP then encoded before being sent. My problem is that I don’t know how to code it. This is the JMail code that I am working with: I need some help in getting the code other than (Jmail.addAttachment) for adding the attachment.

Can someone please help
?

Dim Jmail
Set JMail = Server.CreateObject("JMail.SMTPMail")
JMail.ServerAddress = "MAILSERVER"
Jmail.AddRecipient("CylPriceList@parker.com")
Jmail.AddRecipient("wrattliffe@parker.com")
Jmail.Sender = Session("CustEmail")
Jmail.SenderName ="Quote Requestor"
Jmail.Subject = "Quote Request"
Jmail.Priority = 1
Jmail.Body = MailBody
JMail.AddAttachment("filename")
Jmail.Silent = false
Jmail.Execute
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old May 6th, 2006, 20:31
Up'n'Coming Member
Join Date: Apr 2006
Location: Missouri
Age: 32
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Adding Attachments with JMail

I beleive you are going to need to go and get an upload component because that is where your problem resides. If you are not trying to upload files then the JMail.AddAttachment would be:
JMail.AddAttachment ("Path to file located on the webserver")
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old May 9th, 2006, 16:59
New Member
Join Date: Apr 2006
Location: ILLINOIS
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Adding Attachments with JMail

Quote:
Originally Posted by lesleindotcom
I beleive you are going to need to go and get an upload component because that is where your problem resides. If you are not trying to upload files then the JMail.AddAttachment would be:
JMail.AddAttachment ("Path to file located on the webserver")
Thanks, do you have any suggestions as to which one I should use. I googled 'File Upload' and there's a lot out there.

Wanda
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old May 9th, 2006, 17:02
Up'n'Coming Member
Join Date: Apr 2006
Location: Missouri
Age: 32
Posts: 65
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Adding Attachments with JMail

www.aspin.com search for upload
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old May 11th, 2006, 00:48
Rob's Avatar
Rob Rob is online now
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,157
Blog Entries: 7
Thanks: 26
Thanked 19 Times in 16 Posts
Re: Adding Attachments with JMail

To be honest, I would go for a pure ASP file upload, negating the need for any third party objects. Obviously however, if your server already has an upload object, then use that as it's compiled, and hence quicker.

Most hosts however wont install COM objects over and above what they initially offer..... so better check with them before buying anything.

My advice is to ask them if they already have an upload component and take it from there.

If all else fails, then a Pure ASP Upload class could be dug out of the closet for you, I'm sure.
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old May 12th, 2006, 19:03
New Member
Join Date: Apr 2006
Location: ILLINOIS
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Adding Attachments with JMail

Quote:
Originally Posted by Rob
To be honest, I would go for a pure ASP file upload, negating the need for any third party objects. Obviously however, if your server already has an upload object, then use that as it's compiled, and hence quicker.

Most hosts however wont install COM objects over and above what they initially offer..... so better check with them before buying anything.

My advice is to ask them if they already have an upload component and take it from there.

If all else fails, then a Pure ASP Upload class could be dug out of the closet for you, I'm sure.
Hi Rob,

I have found the code for a Pure ASP UpLoad, but I'm having a problem integrating the code into my application. Do you think you'd be able to guide in the right direction if I provided you with my code
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old May 12th, 2006, 20:03
Rob's Avatar
Rob Rob is online now
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,157
Blog Entries: 7
Thanks: 26
Thanked 19 Times in 16 Posts
Re: Adding Attachments with JMail

Well, just let us know exactly what upload script you are using, and what part you are having trouble with....
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old May 18th, 2006, 19:19
New Member
Join Date: Apr 2006
Location: ILLINOIS
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Adding Attachments with JMail

Quote:
Originally Posted by Rob
Well, just let us know exactly what upload script you are using, and what part you are having trouble with....
Hi Rob,

I'm back and here is the situation...

I am using Pure ASP Upload 2.2.1 which is a dreamweaver extension. I've got the code inserted where it should be...but I keep getting the error message "Cannot call BinaryRead after using Request.Form collection". I know that I need to use the ObjUploadRequest in place of Request.form and only after the upload executes. However, I do not know where to add the code...I'm attaching the code. I hope you can help me. Thanks in advance

I've attached the code for the form I'm trying to add the code to...

Maybe it would be easier if I just created a popup box that is used to upload and after the files are uploaded it returns to the verification page to submit? Does that sound do-able?

Hi Rob,

Are you able to help me?
Attached Files
File Type: txt PureASPUploadProblem.txt (26.7 KB, 49 views)

Last edited by wacara; May 23rd, 2006 at 16:01.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Jun 8th, 2006, 20:12
New Member
Join Date: Apr 2006
Location: ILLINOIS
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs down Re: Adding Attachments with JMail

Quote:
Originally Posted by Rob
Well, just let us know exactly what upload script you are using, and what part you are having trouble with....
Hi Rob,

I'm using 20/20 Applications Pure-ASP Upload. It works great as far as uploading the files to my server. Now I have another question. Can you tell me how to attach the file from my server to the email. What I need to happen is when a user attaches a file, the files is uploaded to the server and then when they click on finish the email is sent with the file attached to it. I'm using the JMail funcion.

Code: Select all
Dim strFileName
Dim Jmail
Set JMail = Server.CreateObject("JMail.SMTPMail")
Set attachment = FileUpload(strFileName)
JMail.ServerAddress = "MAILSERVER"
Jmail.AddRecipient("CylPriceList@parker.com")
Jmail.AddRecipient("wrattliffe@parker.com")
Jmail.Sender = Session("CustEmail")
Jmail.SenderName ="Quote Requestor"
Jmail.Subject = "Quote Request"
Jmail.Priority = 1
Jmail.Body = MailBody
JMail.AddAttachment ("d:\web\www.parker.com\cylinder\tempUploads\file.txt")
Jmail.Silent = false
Jmail.Execute
Here's part of the code for the upload utility...

Code: Select all
<%@ Language="VBScript" %>
<!--#include file="_cls2020Upload.asp"-->
<%
dim t1,t2
t1 = Timer()
' TIP: Delete all the comments to see the code
' flow more clearly.

' Define a variable to store the clsUpload object.
dim objUpload

' Instantiate the clsUpload object.
set objUpload = New clsUpload

' Turn on file extensions restriction.
    objUpload.RestrictFileExtentions = True

' Set a list of known "safe" file extensions.
    objUpload.SafeFileExtensions = "doc|dwg|xls|txt|jpg|gif|tif|html|bmp"

' Call the Upload() method to retrieve data from
' the HTTP header. Prepare for failure.
' Just as example, I've set the path to "" in this
' case.  You could set the folder path here, or as
' in this example you can set the folder path for
' each file.
' (look for the objFile.UploadPath stuff later).
    IF NOT objUpload.Upload("d:\web\www.parker.com\cylinder\tempUploads") THEN
    %>
    <p><%=err.Number &": "& err.Description%>
    <%
    END IF

' As a courtesy, I'll write some data to the page.
' Note that Windows Server 2003 imposed a 200 kilobyte size restriction
' on HTTP headers called "AspMaxRequestEntityAllowed"
' This is documented here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissdk/html/99b8a8bd-f9e7-43a8-b4cf-1186e2b3e9e2.asp
response.write("<p>Total Bytes Uploaded: "& objUpload.TotalBytes &"</p>")

' Check if some files exists in the HTTP header.
    IF objUpload.Files.Count = 0 THEN
    %>
    <p>No files were uploaded or file extension not allowed.</p>
    <%
' If there are files, then let's proceed.
    ELSE

' Create variables for later use.
    dim item
    dim objFile
    dim strFileName
    dim strFileExtension

' Loop through the file objects.
        FOR EACH item IN objUpload.Files

' Set the objFile variable to a reference to this item in the Files collection.
        set objFile = objUpload.Files(item)

' Check to see that the folder exists. (We can do this before "saving" the file.)
            IF NOT objFile.FolderExists THEN
            %>
            <p>Folder doesn't exist.  Will reset the folder to: 
            <%
' In this example, I KNEW that the folder wouldn't exist, so I'll reset that
' property here.
            objFile.UploadPath = Replace(server.MapPath(request.servervariables("SCRIPT_NAME")),Mid(request.servervariables("SCRIPT_NAME"),2),"")
' I've reset the "UploadPath" property, so now I'll explicitly call the
' "BuildPath()" method just as a courtesy.
            objFile.BuildPath
            %><%=objFile.UploadPath%></p>
            <%
            END IF

' Let's grab the file name.
        strFileName = objFile.FileName

' And write more stats to the page.
        response.write("<p>File: "& strFileName &"<br />Size: "& objFile.Size &"<br />Content-Type:"& objFile.ContentType)

' We can check to see if this is a duplicate file name.
            IF objFile.FileExists THEN
' Grab the file extension.
            strFileExtension = LCase(Right(strFileName,Len(strFileName) - InStrRev(strFileName,".")))
' Make a new file name.
            strFileName = objFile.Size &"-"& Replace(CDbl(Now()),".","") &"."& strFileExtension
' Reset the file name.
            objFile.FileName = strFileName
' More stats.
            response.write("<br />File Already Exists.  Name changed to: "& strFileName)
            END IF

' Now "Save" the file. (Prepare for failure.)
            IF NOT objFile.Save THEN
            %>
            <p>Cannot save file.</p>
            <%
            ELSE
' Great!
            %>
            <p>File Uploaded and Saved to <%=objFile.UploadPath%></p>
            <%
            END IF

        response.write("</p>")

' Cleanup the file object.
        set objFile = nothing

        NEXT

    END IF

' Check if some form elementss exist in the HTTP header.
    IF objUpload.Form.Count = 0 THEN
    %>
    <p>No form elements exist.</p>
    <%
' If so, then let's just write them to the page.
    ELSE

' Create a variable to store the dictionary item.
    dim element

' Then loop through them and write them to the page.
        FOR EACH element IN objUpload.Form
        %>
        <p>Name: <%=element%><br />Value: <%=objUpload.Form(element)%></p>
        <%
        NEXT

    END IF

' Cleanup
set objUpload = nothing

t2 = Timer()
response.write("Time: "& t2-t1)
%>
Can you help me
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
adding, attachments, jmail

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem sending Multiple Attachments w/Email wacara Classic ASP 0 Aug 9th, 2007 19:50
jmail for dummie's frankc PHP Forum 1 Jun 13th, 2007 20:01
JMail ClaireB Classic ASP 9 Sep 12th, 2005 12:02


All times are GMT. The time now is 16:57.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42