Solved

Email an attachment in ASP

Posted on 2002-04-29
8
473 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 50 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reg Exp to extract Url from string asp 12 39
Date on a table 16 35
Want an individual results display div 8 46
Table header must be on top 2 30
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…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 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