Click here to Skip to main content
Licence 
First Posted 28 Apr 2002
Views 111,630
Bookmarked 34 times

Send ASP email with attachments

By | 28 Apr 2002 | Article
Send ASP email with attachments

Introduction

This article shows how to send an email with attachments using the CDONTS component.

Many ASP programmers want to know how to do this and with the arrival of IIS4 and the SMTP service of Option Pack 4 it is now fairly easy. There is a component that is made available after the server installation of SMTP service. It is called CDONTS and it makes sending email rather easy. Setting up the SMTP service properly is up to you. It is fairly self explanatory and I have never had any problems installing it. Any quality ISP's who offer ASP hosting should already have this set up on their servers.

<%
Sub send_email(strEmail_from, strEmail_to, strEmail_subject, _
  strEmail_body, strEmail_attach)
    Dim Newmail
    Set newmail = server.CreateObject ("cdonts.newmail")

    newmail.bodyformat = 0
    newmail.mailformat = 0
    newmail.from = strEmail_from
    newmail.to = strEmail_to
    newmail.subject = strEmail_subject
    
    If strEmail_attach <> "" then
        newmail.AttachFile(strEmail_attach)
    End If
    
    newmail.body = strEmail_body
    newmail.send
    Set newmail = Nothing    
End Sub
%>

Call Example:

Call send_email("Email_from", "Email_to", "Email_subject", _
    "Email_body", "c:\file.doc")

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Fernando Finelli

Web Developer

Argentina Argentina

Member

Lic. Fernando Finelli

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralEnvio de adjuntos con cdonts Pinmemberla productora4:52 22 Jun '09  
Questionhow to attach file from local system PinmemberY_Kaushik22:06 5 Aug '07  

Hello All's
I am New in asp ...
I am writing an script for sending email with attachment in asp
when i upload this file it show page can not be displayed
my code is below can any one told me where i am wrong
 
resum=Request.Form("fille1")
 

Dim myMail
Set myMail = CreateObject("CDONTS.NewMail")
myMail.From = "resume@test.com"
myMail.To = "yogendra.kaushik@gmail.com"
myMail.Subject = "Resume submission from website."
'myMail.AddAttachment Server.MapPath("resum")
myMail.AttachFile("resum")
myMail.BodyFormat = 0
myMail.MailFormat = 0
myMail.Body = fulldisplay
myMail.Send
Set myMail = Nothing
response.Redirect("msg.asp")
 
Please help me if any body can.........

 
Regard's
Kaushik

QuestionWhere is the Attachment??? Pinmemberalanshen2099:49 18 Feb '05  
AnswerRe: Where is the Attachment??? PinmemberNicebrilliant19:31 4 Jun '07  
AnswerRe: Where is the Attachment??? PinmemberNicebrilliant19:33 4 Jun '07  
GeneralCDONTS.DLL File PinsussAnonymous10:21 27 Mar '03  
GeneralRe: CDONTS.DLL File PinmemberValer BOCAN23:15 28 Jul '03  
Generalfdgfdg PinsussAnonymous5:50 9 Sep '02  
Generalsend email Pinmembershotgun11:14 11 Jul '02  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120529.1 | Last Updated 29 Apr 2002
Article Copyright 2002 by Fernando Finelli
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid