Send a mail with PHP ASP or Java 2
Posted on 7th April 2006 by Keith DsouzaOkay in my earlier article I explained how a mail can be sent using PHP, continuing with the second part I am now going to explain how an email can be sent using ASP
Sending a email with ASP is also as simple as sending it with PHP. ASP also has an inbuilt object that can be used to send a mail.
'Function used to send a mail
'@param strToEmail, strFromEmail, strCCEmail, strBCCEmail, strSubject, strBody of the email
Function sendMail(strToEmail, strFromEmail, strCCEmail, strBCCEmail, strSubject, strBody)
Dim Cdonts, eStr
Set Cdonts = Server.CreateObject("CDonts.Newmail")
Cdonts.To = strToEmail
Cdonts.CC = strCCEmail
Cdonts.BCC = strCCEmail
Cdonts.From = strFromEmail
Cdonts.Subject = strSubject
Cdonts.BodyFormat=0 'set format to html
Cdonts.MailFormat=0 'set format to html
Cdonts.Body = strBody
Cdonts.Send ' send the mail
If err.Number <> 0 Then
sendMail = False
'Response.write "Failed sending the mail"
Else
sendMail = True
'Response.write "Success sending the mail"
End If
End Function 'end sendMail
Here is the explanation for the above code
Set Cdonts = Server.CreateObject("CDonts.Newmail")
This creates a reference to the the inbuilt object CDonts.Newmail which will be used to send the email
Cdonts.To = strToEmail
Cdonts.CC = strCCEmail
Cdonts.BCC = strBCCEmail
Cdonts.From = strFromEmail
Cdonts.Subject = strSubject
Set the to, from, cc, bcc and subject headers for the email
Cdonts.BodyFormat=0 'set format to html
Set the body format for the mail to html, this will allow you to use html tags in your email
Cdonts.MailFormat=0 'set format to html
Sets the format of the email to html
Cdonts.Body = strBody
Sets the body of the email
Cdonts.Send ' send the mail
Finally now send an email.
Thats it done with the email sending. Note you will require the CDonts.dll to send a email, you can find that easily by doing a google search with the term cdonts.dll downloads.If anyone is interested in the tutorial for Java, just leave a message, i will write up now or else please wait till i do it.
Additional note, Microsoft has decontinued the Cdonts technology but you can still use it by registering the dll.
Technorati Tags: send email, cdonts, asp mail
