Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Email an attachment in ASP

Posted on 2002-04-29
8
Medium Priority
?
482 Views
Last Modified: 2012-06-22
how does ASP email attachments?
0
Comment
Question by:dbnewbie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 200 total points
ID: 6979277
Where do the attachments reside--on the server or on the client machine?

If on the client machine, then you will need some ASP code for uploading attachments; ASPUpload is a good one and is available at www.persits.com.

On the other hand, if the attachements are on the server, you just add a parameter to your mail code to pick up the attachment. What are you using? CDO, ASPemail, JMail?

Here is an example with ASPemail (available for free at www.persits.com):

Set objMail = Server.CreateObject("Persits.MailSender")
                                   
     strBody =     "Place your body text here!"

     objMail.Host = "mail.yourdomain.net"
     objMail.From = strFromAddress
     objMail.FromName = strFromName
     objMail.AddAddress objRSMailProcess("strEmailAddress")
     objMail.AddAttachment strAttachment 'the path and file name goes here!
     objMail.Subject = strSubject
     objMail.Body = strBody
     On Error Resume Next
     objMail.Send
     objMail.ResetAll
                         
     If Err <> 0 Then
        Response.Write "Error encountered: " & Err.Description
     End If                        

Set objMail = nothing
0
 
LVL 1

Expert Comment

by:choroque
ID: 6979323
This one's using SMTP Object available in Windows NT and Windows 2000 :

<%
     Dim objCDO
     Set objCDO = Server.CreateObject("CDONTS.Newmail")

     objCDO.To = "somebody@somewhere.com"
     objCDO.Cc = "somebody2@somewhere.com"
     objCDO.From = "me@here.com"
     objCDO.Subject = "Hi"
     objCDO.Body = "the body of the mail goes here"
     objCDO.AttachFile "c:\myfile.zip"
     
     objCDO.Send

     set objCDO = nothing
%>

you can use your own variable when using all those properties.



0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 6979404
Both of the examples above, however, assume that your attachment resides on the server, not the client machine.

CDO is available only Windows 2000 Server. If you are running Windows NT, the code would be:

dim objMail
set objMail = CreateObject("CDONTS.Newmail")
     objMail.From = You@YourAddress.com
     objMail.To = strEmailAddress  
     objMail.Subject = "Email Request"
     Msg = "This is the first line of your message" & Chr(10)
     Msg = Msg & "This is the second line of your message... and so forth"
     objMail.Body = Msg
        objMail.AttachFile "c:\yourpath\yourfile.ext"
     objMail.Send
     Set objMail = Nothing
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:loveneesh_bansal
ID: 6979506
Good Answer
0
 
LVL 2

Expert Comment

by:zombeen
ID: 6979651
just remeber to always use absolute path ("C:\..\..\..\myfile.txt") of your file on the server and not relative.
0
 
LVL 1

Expert Comment

by:giladBoker
ID: 6980805
the answer is same as the others but...

if u r using the persist xupload object u can attach files dinamcly.

just upload few files to the x-upload object and then

for each item in xuploadName
    mailObject.attachFile(item.path)
next

I did it in my sites it works
0
 

Author Comment

by:dbnewbie
ID: 6985501
will work on this on the weekend. patience please. thanks.
0
 
LVL 1

Expert Comment

by:giladBoker
ID: 6985550
good luck
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question