Solved

Email an attachment in ASP

Posted on 2002-04-29
8
469 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 …
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

11 Experts available now in Live!

Get 1:1 Help Now