newbee question about sending parameters

From: Ralf Meuser (rmeuser_at_free.fr)
Date: 06/08/04


Date: Tue, 8 Jun 2004 08:46:59 +0200

Hi there

I have to send mails from line commands.
I have been told to use cdo and so I found the follwing script.

The script works like this, but I would like to modify the script so that I
can send objMessage.To as a variable and a name of a textfile for
objMessage.TextBody.

I just started using vbscript and I didn't find how to do this.

Thanks in adavance for any help

Ralf

------------------------------------------
'Sending a text email using authentication against a remote SMTP server
' Sample code submitted by Clint Baldwin, +1 (918) 671 3429
Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2
Const cdoAnonymous = 0
' Use basic (clear-text) authentication.
Const cdoBasic = 1
' Use NTLM authentication
Const cdoNTLM = 2 'NTLM

' Create the message object.
Set objMessage = CreateObject("CDO.Message")
'Set the from address this would be your email address.
objMessage.From = """Toto Tata""<toto.tata@domain.com>"
' Set the TO Address separate multiple address with a comma
objMessage.To = "titi.titi@domain2.com"
' Set the Subject.
objMessage.Subject = "An Email From Active Call Center."
' Now for the Message Options Part.
' Use standared text for the body.
objMessage.TextBody = _
"This is some sample message text.." & _
vbCRLF & _
"It was sent using SMTP authentication."

' Or you could use HTML as:
' objMessage.HTMLBody = strHTML

' ATTACHMENT : Add an attachment Can be any valid url
objMessage.AddAttachment("file://C:/tmp/kg30.out")

' This section provides the configuration information for the SMTP server.
' Specifie the method used to send messages.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = _
cdoSendUsingPort

' The name (DNS) or IP address of the machine
' hosting the SMTP service through which
' messages are to be sent.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"mail.domain.com" ' Or "mail.server.com"

' Specify the authentication mechanism
' to use.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = _
cdoBasic

' The username for authenticating to an SMTP server using basic (clear-text)
authentication
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = _
"toto.toto@domain.com"

' The password used to authenticate
' to an SMTP server using authentication
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = _
"mypassword"

' The port on which the SMTP service
' specified by the smtpserver field is
' listening for connections (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = _
25

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = _
False

' Set the number of seconds to wait for a valid socket to be established
with the SMTP service before timing out.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = _
60

' Update configuration
objMessage.Configuration.Fields.Update

' Use to show the message.
' MsgBox objMessage.GetStream.ReadText

' Send the message.
objMessage.Send



Relevant Pages

  • ASP mailing script not sending mail
    ... I have the following script which notfies the Webmaster when a user logs on. ... ' Please provide the following details for your SMTP server ... Const USE_AUTHENTICATION = True ... If varStart And varStop Then strIP = Mid(strHTMLText, varStart, varStop - ...
    (microsoft.public.windows.server.scripting)
  • EMail script fails from Server 2008 only
    ... Basically I have a script that sends emails after backup jobs complete. ... If I run it from a server 2008 machine I get a logon box which comes from ... then the email works so it obviously picks up the authentication ... 'Name or IP of Remote SMTP Server ...
    (microsoft.public.scripting.vbscript)
  • Re: Outlook Script to Send email
    ... Blat is not an SMTP server. ... SMTP Service" give me an authentication error because this script does not ...
    (microsoft.public.scripting.vbscript)
  • MIME::Lite and smtp auth
    ... I want send mail with attachments through smtp server with ... authentication. ... I found script which use Mime::lite and added ... as CPAN says, but don't act properly. ...
    (comp.lang.perl.misc)
  • Re: ADSI Problem
    ... Right I've got the script working now with my ASP applications by passing the ... If you are doing forms authentication using ADSI (which it sounds like you ... Restarting IIS usually gets it working again. ... Dim strUserName ...
    (microsoft.public.windows.server.active_directory)

Loading