Solved

Email an attachment in ASP

Posted on 2002-04-29
8
470 Views
Last Modified: 2012-06-22
how does ASP email attachments?
0
Comment
Question by:dbnewbie
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
 
LVL 1

Expert Comment

by:loveneesh_bansal
ID: 6979506
Good Answer
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

896 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now