Total members 10249 | Gratitudes |It is currently Thu May 17, 2012 7:16 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Code Snippet
 Code subject: Send email in asp
PostPosted: Fri Apr 08, 2011 8:41 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2272
Location: Earth
Has thanked: 39 time
Have thanks: 61 time

Send email in asp function creation and call it later in code snippet .
Code:
<html>
<%
 
    
End Sub
Function sendMail
(ByVal mailTo, ByVal mailFrom, ByVal mailSubject, ByVal mailBody)
   
    Dim objMailSender 
= Server.CreateObject("CDONTS.NewMail")
    objMailSender.To = mailTo
    objMailSender
.From = mailFrom
    objMailSender
.Subject = mailSubject
    objMailSender
.Body = mailBody
    objMailSender
.Send()
    objMailSender = Nothing
    If Err Then
        SendMail 
= False
    Else
        SendMail 
= True
    End If
End Function
%> 
 
<p>Calling the send mail function</p>
<%
 
sendMail 
"codemiles@codemiles.com" , "codemiles@codemiles.com" , "Mail Subject" , "Mail Body" 
%>
</
html>
 



You also add attachment to email like this
Code:
<% 
    Dim objMailSender
    
'create an instance of CDONTS 
    objMailSender = Server.CreateObject("CDONTS.NewMail")
    '
From  Email
    objMailSender
.From = "codemiles@codemiles.com"
    'TO Email.
    objMailSender.To = "codemiles@codemiles.com"
    '
Email Subject
    objMailSender
.Subject = "subject:contains attach"
    'File path to be attached 
    objMailSender.AttachFile("c:\img.gif")
    '
Email body
    objMailSender
.Body = "Email body."
    Send the Email
    objMailSender
.Send()
    objMailSender = Nothing
%>
 


You also add HTML to your email body , example
Code:
<% 
    
'create objects.
    Dim objEmailSender, strHTMLContent
    objEmailSender = Server.CreateObject("CDONTS.NewMail")
    '
Add some html 
    strHTMLContent 
= strHTMLContent & "<html><head><title>Title</title></head>"
    strHTMLContent = strHTMLContent & "<body>"
    strHTMLContent = strHTMLContent & "<p>Paragraph part</p>"
    strHTMLContent = strHTMLContent & "<br><hr>"
    strHTMLContent = strHTMLContent & "<b>Bold string</b>"
    strHTMLContent = strHTMLContent & "<a href=""#"">link</a>"
    strHTMLContent = strHTMLContent & "</body></html>"
    'From Email
    objEmailSender.From = "codemiles@codemiles.com"
    '
To Email
    objEmailSender
.To = "codemiles@codemiles.com"
    'Subject
    objEmailSender.Subject = "HTML email"
    '
 The body is HTML content
    objEmailSender
.Body = strHTMLContent
    
    
'Used to format html emails.
    objEmailSender.BodyFormat = 0
    objEmailSender.MailFormat = 0
     
    
    '
Send the Email.
    objEmailSender.Send()
    objEmailSender = Nothing
%>
 

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 i want code for connecting mobile and pc can u send me code
 Send email link example.
 How to upload and retrieve image in jsp please send me code
 Email validation in Javascript
 i want to send conformation email with user details on the
 How to send conformation e-mail through JSP
 read email inbox ASP
 validate email address in asp
 Send an email in asp.net
 Send login information

All times are UTC [ DST ]


Users browsing similar codes

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Code Snippet | Next Code Snippet  cron




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team