Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     

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

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:


            CDO.Message oMsg = new CDO.Message();
            CDO.IConfiguration iConfg;
            iConfg = oMsg.Configuration;
            ADODB.Fields oFields;
            oFields = iConfg.Fields;
            ADODB.Field oField = oFields["
            oMsg.Subject = "Test CDO";
            oMsg.From = "";
            oMsg.To = "";
            //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 = ""
oMsg.[To] = ""
'oMsg.TextBody = "CDO Mail test";
oMsg.HTMLBody = "CDO Mail test"
Response.Write("Mail Sent")

Share this article   |    Print    |    Article read by 6172 times
Rohit kakria
I am software developer, moderator of
Related Articles: No related article
Related Interview Questions: No related interview question