Question : How to get CDO.Message working in VBScript on Vista Business

Hi,

I'm trying to pass parameters to CDO Message to send an e-mail but can't get it to work.

The code I have is as follows :-

Sub SendEmailMessage(ByVal strDestEmail, ByVal strNTName, ByVal dtmDate)
    ' Send email message.
   
dim objEmail

Set objEmail = CreateObject("CDO.Message")
objEmail.From = "IT Department"
objEmail.To = strDestEmail
objEmail.Subject = "Password expiry test e-mail"
objEmail.Textbody = "your password is going to expire."
objEmail.sendusing = 2
objEmail.smtpserver = "myexchangeserver"
objEmail.smtpserverport = 25
objEmail.Configuration.Fields.Update
objEmail.Send

End Sub

I'm encountering errors with the following lines :-

objEmail.sendusing = 2
objEmail.smtpserver = "myexchangeserver"
objEmail.smtpserverport = 25

and get the error message :-

CDO.Message.1 The "SendUsing" configuration value is invalid

Thanks for your help.

Answer : How to get CDO.Message working in VBScript on Vista Business

Here's my version of pretty much the same

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "A subject"
objMessage.From = "[email protected]"
objMessage.To = "[email protected]"
objMessage.TextBody = "Hi someone else."
objMessage.AddAttachment "c:\test.txt"

'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "192.168.10.1"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send
 

Random Solutions  
 
programming4us programming4us