Programming Tutorials

Sending email using CDOSYS in VB.net

By: Issac in VB.net Tutorials on 2009-02-21  

You can also send email by using CDOSYS in VB.NET. For sending email using CDOSYS, you have to send email from Windows 2000/XP and also you have to be enabled SMTP Service in IIS.

Requirements:
Windows XP/ Windows2000
Internet Information Services (IIS)
SMTP Services in IIS should be enabled

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, 
	ByVal e As System.EventArgs) Handles Button1.Click
        Dim CDOSYS As Object
        Const cdoSendUsingPickup = 1
        Const strPickup = "c:\inetpub\mailroot\pickup"
        CDOSYS = CreateObject("CDO.Message")

        CDOSYS.Configuration.Fields.item _
	("http://schemas.microsoft.com/cdo/configuration/sendusing") _
	= cdoSendUsingPickup

        CDOSYS.Configuration.Fields.item _
	("http://schemas.microsoft.com/cdo/configuration" & _
	/smtpserverpickupdirectory")  _
	= strPickup

        CDOSYS.Configuration.Fields.Update()
        CDOSYS.To = "TO ADDRESS"
        CDOSYS.From = "FROM ADDRESS"
        CDOSYS.Subject = "CDO Test"
        CDOSYS.TextBody = "Send Email from vb.net using CDOSYS"
        CDOSYS.Send()
        CDOSYS = Nothing
        MsgBox("mail send")
    End Sub
End Class

For this to happen, you have to provide the informations like To Address, From Address and it is very important to enable your SMTP services in IIS.





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in VB.net )

Latest Articles (in VB.net)