Share via


Sending a Message Using CDOEX

Topic Last Modified: 2006-06-11

Example

Visual Basic

'Sending a Message via CDO
'Reference the project with CDO for Exchage 2000 and ADO 2.5 libraries


Private Sub Main()
'Sending Mail Message Using Exchange Server

Dim oMessage As CDO.Message
'Create a Message Object
Set oMessage = CreateObject("CDO.Message")

With oMessage
'Set the properties
.To = InputBox("Enter the recipient's e-mail address")
.From = InputBox("Enter the sender's e-mail address")
.TextBody = "This is a sample Body" 'Your TextBody
.Subject = "This is a sample Subject" 'Your Subject
.Configuration.Fields("CdoSendUsing") = cdoSendUsingExchange 'Using Exchange Server
.Configuration.Fields.Update
.AddAttachment ("c:\file1.txt")
.CreateMHTMLBody "http://www.example.com"
.Send
End With

End Sub