keschuster
asked on
Sending email with vbscript thru Exchange Server
I have a remote desktop that I process files on. I'm trying to automate. I have an account on the company exchange server no different then anyone elses. Is it possible to send myself and email using vbscript through my exchange server account.
There isn't outlook or anything on the machine so I don't do email on that machine now - if that matters
thanks
There isn't outlook or anything on the machine so I don't do email on that machine now - if that matters
thanks
CDO works for me generally. used from Excel.
Set objConf = CreateObject("CDO.Configuration")
With objConf.fields
.item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = sMailServerName
.item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous 'cdoBasic
'.item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "your-username"
'item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "your-password"
.Update
End With
Set objMsg = CreateObject("CDO.Message")
objMsg.Configuration = objConf
With objMsg
'.to = "test@qwerty.com"
.From = "mail@zxcvbn.com.au"
.Subject = Space(2) & Trim(tcSubject)
.TextBody = "what"
'use .HTMLBody to send HTML email.
.AddAttachment lcAttName
.fields("urn:schemas:mailheader:disposition-notification-to") = "mail@zxcvbn.com.au"
.fields("urn:schemas:mailheader:return-receipt-to") = "mail@zxcvbn.com.au"
.DSNOptions = cdoDSNSuccessFailOrDelay
.fields.Update
.Send
End With
Set objMsg = Nothing
NewMail = True
ASKER
I'm running from vbs script on my desktop within the network.
Set objMessage = CreateObject("CDO.Message" )
objMessage.Subject = "Example CDO Message"
objMessage.From = "myemail@email.com"
objMessage.To = "myemail@email.com"
objMessage.TextBody = "This is some sample message text."
objMessage.Send
generates this error
The "SendUsing" configuration value is invalid"
Code: 80040220
Source: CDO.Message.1
Any ideas?
Set objMessage = CreateObject("CDO.Message"
objMessage.Subject = "Example CDO Message"
objMessage.From = "myemail@email.com"
objMessage.To = "myemail@email.com"
objMessage.TextBody = "This is some sample message text."
objMessage.Send
generates this error
The "SendUsing" configuration value is invalid"
Code: 80040220
Source: CDO.Message.1
Any ideas?
You need to specify the mail server you want to send the message via:
objMessage.SMTPServer = "myserver.mydomain.com"
the string can be a shortname, a FQDN, or an ip address, as long as it's routeable.
objMessage.SMTPServer = "myserver.mydomain.com"
the string can be a shortname, a FQDN, or an ip address, as long as it's routeable.
ASKER
Set objMessage = CreateObject("CDO.Message" )
objMessage.SMTPServer = "server.COM"
objMessage.Subject = "Example CDO Message"
objMessage.From = "email@email.com"
objMessage.To = "email@email.com"
objMessage.TextBody = "This is some sample message text."
objMessage.Send
Now I get error - Object doesn't support this property or method:'objMessage.smtpser ver'
objMessage.SMTPServer = "server.COM"
objMessage.Subject = "Example CDO Message"
objMessage.From = "email@email.com"
objMessage.To = "email@email.com"
objMessage.TextBody = "This is some sample message text."
objMessage.Send
Now I get error - Object doesn't support this property or method:'objMessage.smtpser
oops, my bad. .SMTPServer is a property of the CDO configuration, not the message. you'd need to specify that first. I'd write the code for you but robberbaron already has. Look at lines 1-13 on the script he posted. Those should work for you (modified for your needs of course)
ASKER
I found solution using activex
google Chilkat
google Chilkat
AspEmail does the same sort of thing. It has a freeware component. chilkat is not.
CDO is lower level than these and is MS download for use with Exchange.
CDO is lower level than these and is MS download for use with Exchange.
ASKER
"CDO is lower level than these and is MS download for use with Exchange."
for use with exchange? Were do I get more information on this? I can use this to send email via BAT file for VBS?
for use with exchange? Were do I get more information on this? I can use this to send email via BAT file for VBS?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I get an error message on line 65
"The Server rejected one or more recipient addresses. the server reponse was:550 5.7.1. Unable to relay for Keithschsuter@gmail.com
I'm running this on the company network and pointing to the exchange server.
Any ideas?
"The Server rejected one or more recipient addresses. the server reponse was:550 5.7.1. Unable to relay for Keithschsuter@gmail.com
I'm running this on the company network and pointing to the exchange server.
Any ideas?
ASKER
I changed authentication to = 2 and it WORKED!!!
Thanks
Thanks
If so, then you won't need to authenticate, it will be as simple as pointing any VBScript to the Exchange server and using it like a normal SMTP server
I am no scripter, but the first link I found on doing this showed good results;
http://forums.devx.com/showthread.php?threadid=21954
As you don't have Outlook, skip suggestions 2 and 3, but 1 and 4 are good options.
Kieran