Xpode.com        Click here to Print this article.

Send mail using CDO.Message

Some time we have requirement that we have to send a mail without SMTP information or On Server SMTP is now allowed or install. Then we may send mail using CDO instead of SMTP server. For send the mail using CDO, we have to add reference of Microsoft CDO for Windows 2000 Library. Please check the steps. (1) Add reference for "Microsoft CDO for Windows 2000 Library" Check image.

Adding reference of CDO In asp.net

Now there will be two references for:

Interop.CDO.dll (2) Create CDO.Message object
(3)Create attribute for CDO.IConfiguration
(4) Check the connfiguration
(5) Add ADODB Fields (for send using)
(6) Now update the field information means there is no more field
(7) Now add Subject, From, To Information, HTML Body
(8) Yippy I love this line always "SendMail" with message object.

Now on button click write the below code on button click:

IN C#.net

            CDO.Message oMsg = new CDO.Message();
            CDO.IConfiguration iConfg;
            iConfg = oMsg.Configuration;
            ADODB.Fields oFields;
            oFields = iConfg.Fields;
            ADODB.Field oField = oFields["http://schemas.microsoft.com
            oMsg.Subject = "Test CDO";
            oMsg.From = "Rohit.kakhria@pugmarks.com";
            oMsg.To = "kakriarohit@gmail.com";
            //oMsg.TextBody = "CDO Mail test";
            oMsg.HTMLBody = "CDO Mail test";
            Response.Write("Mail Sent");

in VB.Net

Dim oMsg As New CDO.Message()
Dim iConfg As CDO.IConfiguration
iConfg = oMsg.Configuration
Dim oFields As ADODB.Fields
oFields = iConfg.Fields
Dim oField As ADODB.Field = oFields("http://schemas.
oMsg.Subject = "Test CDO"
oMsg.From = "Rohit.kakhria@pugmarks.com"
oMsg.[To] = "kakriarohit@gmail.com"
'oMsg.TextBody = "CDO Mail test";
oMsg.HTMLBody = "CDO Mail test"
Response.Write("Mail Sent")


Contributed by:
Rohit kakria
I am software developer, moderator of xpode.com

Resourse address on xpode.com

Click here to go on website