Total members 11895 |It is currently Sat Dec 21, 2024 2:45 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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 
"[email protected]" , "[email protected]" , "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 = "[email protected]"
    'TO Email.
    objMailSender.To = "[email protected]"
    '
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 = "[email protected]"
    '
To Email
    objEmailSender
.To = "[email protected]"
    '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
%>
 




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Send email in asp
 Send an email in asp.net     -  
 send email from ASP using CDOSYS     -  
 Send email link example.     -  
 Send Email from a PHP Script Example     -  
 send confirmation link to email     -  
 i want to send conformation email with user details on the     -  
 Send Email Recipient CC,BCC MimeMultipart, Attachments     -  
 validate email address in asp     -  
 email through JAVA program     -  



Topic Tags

ASP Email
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com