Attribute VB_Name = "Module1"
Sub main()
Dim oMsg As New CDO.Message
Dim oCfg As New CDO.Configuration

oCfg.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'oCfg.Fields(cdosednusingmethod) = cdoSendUsingPort
oCfg.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "ywd\user2"
'oCfg.Fields(cdoSendUserName) = "ywd\user2"
oCfg.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = ""
'oCfg.Fields(cdoSendPassword) = ""
oCfg.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
'oCfg.Fields(cdoSMTPAuthenticate) = cdoBasic
oCfg.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "yws"
'oCfg.Fields(cdostmpserver) = "yws"
oCfg.Fields("http://schemas.microsoft.com/cdo/configuration/smtpaccountname") = "user2 wang"
'oCfg.Fields(cdoSMTPAccountName) = "user2 wang"
oCfg.Fields("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = "user2@ywd.extest.microsoft.com"
'oCfg.Fields(cdoSendEmailAddress) = "user2@ywd.extest.microsoft.com"
oCfg.Fields.Update

Set oMsg.Configuration = oCfg

oMsg.Subject = "Test Message"
oMsg.CreateMHTMLBody ("http://www.microsoft.com")
oMsg.AddAttachment "e:\a.txt"
oMsg.To = "user1@ywd.extest.microsoft.com"
oMsg.From = "user2@ywd.extest.microsoft.com"
oMsg.Send

Set oMsg = Nothing
Set oCfg = Nothing
End Sub
