techpreparation-homepage

Home  Interview Questions  Aptitude Questions  Tutorials  Placement Papers  Search  Resume Guide  Soft Skills  Video  Forum  Blog


Technical Interview Questions

Visual Basic Interview Question
.NET Web Interview Questions
.NET Interview Questions
C# Interview Questions
                              .........More

Source Codes
Asp .NET Source Codes
Asp VB Script Source Codes
                              .........More

Soft Skills
Communication Skills
Leadership Skills
                              .........More

Subscribe to our Newsletters
Name:
Email:

 

 

  

Asp/VB Script Source Codes

Sending E-Mails with ASP Pages

Sending an email with asp is fairly easy, all you need is CDONTS (Collaboration Data Objects for NT Server, installed with IIS), or a special component like AspEmail ( free ) by Persist Software Inc (there are more available).
<P>In this article I'll show how to send emails with CDO, because it's available to everyone and components work in a very similar way. First we have to create instance of the NewMail object.</P><PRE>&lt;%
Option Explicit

Dim objCDOMail
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
%&gt;</PRE>
<P>The methods and property's of this object are very obvious.</P><PRE>&lt;%
objCDOMail.To = "somebody@somewhere.com" 'the destination
objCDOMail.From = "me@mydomain.com" 'the sender
objCDOMail.cc = "info@mydomain.com" 'carbon copy

Dim txtBody
txtBody = "This email has been sent by an asp script"
objCDOMail.Subject = "CDONTS" 'the subject
objCDOMail.Body = txtBody 'the body
objCDOMail.Send 'fire off the email
%&gt;</PRE>
<P>So far it has been pretty easy, hasn't it? There's more.</P><PRE>&lt;%
objCDOMail.AttachFile("c:\wwwroot\mysite\" &amp; _
"MyAttachement.doc", "pricelist.doc")
objCDOMail.Bcc("blind@mysite.com")
objCDOMail.Importance = 1
%&gt;</PRE>
<UL>
<LI>The first rule defines an attachment ("PATH\TO\FILE", filename_that_appears)
<LI>The second rule sends a blind carbon copy
<LI>The third rule specifies the message's importance<BR>&nbsp; Importance:
<UL type=square>
<LI>0 -&gt; low
<LI>1 -&gt; default
<LI>2 -&gt; high </LI></UL></LI></UL>
<P>Thats it, I hope this article has been useful and i hope that now you will feel confident sending automated newsletters, confirmation emails and so on.</P>


<<<----- Return to Asp/VB Script Source Code Questions Page.


Have a Question ? post your questions here. It will be answered as soon as possible.

Check Microsoft .Net Interview Questions for more Microsoft .Net Interview Questions with Answers.

Check .Net Database Interview Questions for more .Net Database Interview Questions with answers

Check Job Interview Questions for more Interview Questions with Answers