?
Solved

Email an attachment in ASP

Posted on 2002-04-29
8
Medium Priority
?
477 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
Independent Software Vendors: 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
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…

770 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