Send a mail with PHP ASP or Java 2

In: Tutorials

7 Apr 2006

Okay 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: , ,  


Related posts:

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Comment Form

About this blog

Hi there. I own several blogs on the Internet, however I still love writing here, because it's my rambling space, no fear, no restrtictions. I write anything and everything here, so keep coming back. Read more about me

Photostream

  • keithdsouza: Look forward to meet you too Sathya :-) [...]
  • Sathya: Looking forward to meet you in Chennai Keith. [...]
  • keithdsouza: @Thilak - I agree, it has to change for the good. BTW, thanks for keeping tabs on the blog and glad [...]
  • Thilak: Nice write up Keith. Actually, the problem with most Indian bloggers is that they blog for some or t [...]
  • Shah Rukh Khan Finally Joins Twitter: [...] "single", "0085A0") }; Quite sometime back I had told you about a fak [...]