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

Send ASP email with attachments

By Fernando Finelli | 28 Apr 2002
Send ASP email with attachments
5 votes, 62.5%
1

2
2 votes, 25.0%
3

4
1 vote, 12.5%
5
1.88/5 - 19 votes
μ 1.88, σa 2.65 [?]

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 productora5:52 22 Jun '09  
Questionhow to attach file from local system PinmemberY_Kaushik23:06 5 Aug '07  
QuestionWhere is the Attachment??? Pinmemberalanshen20910:49 18 Feb '05  
AnswerRe: Where is the Attachment??? PinmemberNicebrilliant20:31 4 Jun '07  
AnswerRe: Where is the Attachment??? PinmemberNicebrilliant20:33 4 Jun '07  
If you are hosting your application on the server, then you need to save first on the server and then provide location of the file located on server.
 
E.g : when you attach file from your local system the path would be like this.
 
"c:\bob.jpg"
 
but while going to attach file,
 
Path would be like this Server.MapPath(" directory location ")
 
Hope will be the answer
 
BOB PK
 
Bob
Nature's Lover.

GeneralCDONTS.DLL File PinsussAnonymous11:21 27 Mar '03  
GeneralRe: CDONTS.DLL File PinmemberValer BOCAN0:15 29 Jul '03  
Generalfdgfdg PinsussAnonymous6:50 9 Sep '02  
Generalsend email Pinmembershotgun12: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
Web04 | 2.5.120210.1 | Last Updated 29 Apr 2002
Article Copyright 2002 by Fernando Finelli
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid