you can also use following code which uses CDO (Collaborating Data Objects)
Dim iMsg as New CDO.Message
Dim iConf as New CDO.Configuration
Dim Flds as ADODB.Fields
Set Flds = iConf.Fields
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServerName) = "somehost@microsoft.com"
.Item(cdoSMTPConnectionTimeout) = 10 ' quick timeout
.Item(cdoSMTPAuthenticate) = cdoBasic
.Item(cdoSendUserName) = "username"
.Item(cdoSendPassword) = "password"
.Item(cdoURLProxyServer) = "server:80"
.Item(cdoURLProxyBypass) = "<local>"
.Item(cdoURLGetLatestVersion) = True
.Update
End With
With iMsg
Set .Configuration = iConf
.To = """User A"" <userA@microsoft.com>"
.From = """User B"" <userB@microsoft.com>"
.Subject = "Hows it going? I've attached my web page"
.CreateMHTMLBody "
.AddAttachment "C:\files\mybook.doc"
.Send
End With