cbones
asked on
Automate Email through vbscript
Hello,
I have the below email script:
Set fso=CreateObject("Scriptin g.FileSyst emObject")
strSMTP="smtpserver.com"
strSubject="hello"
strRecipient=someone@aol.c om,someone @smtpserve r.com"
strSender="someone@smtpser ver.com"
strBody="Hello"
strAttach="C:\test\testfil e.pdf"
If fso.FileExists(strAttach) then
Set iMsg = CreateObject("CDO.Message" )
Set iConf = CreateObject("CDO.Configur ation")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
With iMsg
Set .Configuration = iConf
.To = strRecipient
.CC = ""
.BCC = ""
.From = "<" & strSender & ">"
.Subject = strSubject
.TextBody = strBody
.AddAttachment strAttach
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Else
MsgBox "The specified attachment does not exist"
End if
When I send to an AOL or yahoo account I receive the following error:
"The server rejected one or more recipient address. The server response was: 553 sorry, that domain isn't in my list of allowed rcpthosts(#5.7.1)"
If I send this from my outlook using the same sender and smtp server it sends fine.
Any help would be appreciated.
Thank you.
I have the below email script:
Set fso=CreateObject("Scriptin
strSMTP="smtpserver.com"
strSubject="hello"
strRecipient=someone@aol.c
strSender="someone@smtpser
strBody="Hello"
strAttach="C:\test\testfil
If fso.FileExists(strAttach) then
Set iMsg = CreateObject("CDO.Message"
Set iConf = CreateObject("CDO.Configur
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
With iMsg
Set .Configuration = iConf
.To = strRecipient
.CC = ""
.BCC = ""
.From = "<" & strSender & ">"
.Subject = strSubject
.TextBody = strBody
.AddAttachment strAttach
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Else
MsgBox "The specified attachment does not exist"
End if
When I send to an AOL or yahoo account I receive the following error:
"The server rejected one or more recipient address. The server response was: 553 sorry, that domain isn't in my list of allowed rcpthosts(#5.7.1)"
If I send this from my outlook using the same sender and smtp server it sends fine.
Any help would be appreciated.
Thank you.
There's a great post on this with some very useful code that handles several common email platforms including AOL here:
http://relevantcodes.com/cdo-send-email-from-yahoo-hotmail-live-aol-or-gmail/
If you don't want to use the code there, at least search the code for "aol" and note the differences, like the use of port 587.
~bp
http://relevantcodes.com/cdo-send-email-from-yahoo-hotmail-live-aol-or-gmail/
If you don't want to use the code there, at least search the code for "aol" and note the differences, like the use of port 587.
~bp
ASKER
MacroShadow,
I made those changes but still cannot send to a yahoo or aol user.
Any ideas?
I made those changes but still cannot send to a yahoo or aol user.
Any ideas?
Can you send to a gmail or hotmail account?
btw, you didn't define the sender's smtp account credentials (i.e. username and password.
ASKER
strSMTP="smtpserver.com" --> my smtp server i just renamed it.
strSubject="hello"
strRecipient=someone@aol.c om,someone @smtpserve r.com"
strSender="someone@smtpser ver.com" --> my account just renamed it.
I can send internally. In the same domain, just not out.
Where would I specify that information in the script?
Thank you
strSubject="hello"
strRecipient=someone@aol.c
strSender="someone@smtpser
I can send internally. In the same domain, just not out.
Where would I specify that information in the script?
Thank you
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 added that in. I receive this message:
The transport failed to connect to the server
Code: 80040213
Source: CDO.Message.1
The transport failed to connect to the server
Code: 80040213
Source: CDO.Message.1
That indicates a network related error. Your application cannot connect to the mail server specified.
If the smtpserver is valid - and from you question it seems that it is - it may be a firewall or proxy settings, blocking you.
Your User Name (the user name parameter) should be: YourUsername@yourDomain.co m
If the smtpserver is valid - and from you question it seems that it is - it may be a firewall or proxy settings, blocking you.
Your User Name (the user name parameter) should be: YourUsername@yourDomain.co
I'll be out 'till sunday.
Good luck!
Good luck!
ASKER
Thanks MacroShadow.
I added the @mydomain.com to the below line:
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = username@mydomain.com
but when I do that it tells me invalid characters
I'll keep searching.
I added the @mydomain.com to the below line:
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = username@mydomain.com
but when I do that it tells me invalid characters
I'll keep searching.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I will try the above.
Thank you.
Thank you.
Besides that the problem is most probably caused by not setting the type of authentication to use. Add the following line after With Flds:
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1