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 )