I'd like to send an e-mail with a vbs script. To keep things short, I'll go
straight to the code and the error message:
THE CODE:
schema = "http://schemas.microsoft.com/cdo/configuration/"
Set objEmail = CreateObject("CDO.Message")
With objEmail
.From = "add...@gmx.at"
.To = "add...@gmx.at"
.Subject = "Testmail"
.Textbody = Now & " --> TESTMAIL "
With .Configuration.Fields
.Item (schema & "sendusing") = 2
.Item (schema & "smtpserver") = "mail.gmx.net"
.Item (schema & "smtpserverport") = 25
.Item (schema & "smtpauthenticate") = cdoBasic
.Item (schema & "sendusername") = "add...@gmx.at"
.Item (schema & "sendpassword") = "cleartextpassword"
.Item (schema & "smtpconnectiontimeout") = 30
End With
.Configuration.Fields.Update
.Send
End With
THE EXECUTION (and ERROR):
D:\>cscript //nologo mailing.vbs
D:\mailing.vbs(22, 3) (null): Der Server hat die Absenderadresse
zurückgewiesen. Die Serverantwort lautet: 550 5.7.0 Need to authenticate via
SMTP-AUTH-Login {mp006}
Part of this is in german since I'm running it on a german version of
windows xp pro. The 2 german sentences mean the following:
"Der Server hat die Absenderadresse zurückgewiesen." = "The server has
rejected the senders address."
"Die Serverantwort lautet" = "The server response is"
I've searched quite some time now on how to solve this issue, but couldn't
really find any resources on how to do an SMTP-AUTH-Login with the CDO
stuff?! Anyone has a hint for me?
Kind regards, Chris
>
> THE CODE:
> schema = "http://schemas.microsoft.com/cdo/configuration/"
> Set objEmail = CreateObject("CDO.Message")
>
> With objEmail
> .From = "add...@gmx.at"
> .To = "add...@gmx.at"
> .Subject = "Testmail"
> .Textbody = Now & " --> TESTMAIL "
> With .Configuration.Fields
> .Item (schema & "sendusing") = 2
> .Item (schema & "smtpserver") = "mail.gmx.net"
> .Item (schema & "smtpserverport") = 25
> .Item (schema & "smtpauthenticate") = cdoBasic
> .Item (schema & "sendusername") = "add...@gmx.at"
> .Item (schema & "sendpassword") = "cleartextpassword"
> .Item (schema & "smtpconnectiontimeout") = 30
> End With
> .Configuration.Fields.Update
> .Send
> End With
>
>
> THE EXECUTION (and ERROR):
> D:\>cscript //nologo mailing.vbs
> D:\mailing.vbs(22, 3) (null): Der Server hat die Absenderadresse
> zurÃŒckgewiesen. Die Serverantwort lautet: 550 5.7.0 Need to authenticate via
> SMTP-AUTH-Login {mp006}
>
>
> Part of this is in german since I'm running it on a german version of
> windows xp pro. The 2 german sentences mean the following:
> "Der Server hat die Absenderadresse zurÃŒckgewiesen." = "The server has
> rejected the senders address."
> "Die Serverantwort lautet" = "The server response is"
>
> I've searched quite some time now on how to solve this issue, but couldn't
> really find any resources on how to do an SMTP-AUTH-Login with the CDO
> stuff?! Anyone has a hint for me?
>
possibly only this little line of code is missing..
-- Code --
.Item (schema & "smtpusessl") = vbTrue
-----
Greetings from Germany
Dirk
> Actually I already tried the mailing script with and without the smtpusessl
> setting, but just to ensure that it really doesn't make a difference I tried
> it once again:
> The result is the same error message, also if I change the port number to
> 465 (which is the setting for ssl in my mail client for example).
>
> As far as I know the smtp server requires first to authenticate with the
> pop3 server, is that possible? If so, do you have an idea on how to do that
> via a script, since CDO can only send mails (and not retrieve them), no?
>
it took aliitle time...
I had to create an acount for gmx.
While looking for a solution i found this very interesting page...
http://www.paulsadowski.com/WSH/cdo.htm
used a sample..
--
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = """Me"" <m...@my.com>"
objMessage.To = "te...@paulsadowski.com"
objMessage.TextBody = "This is some sample message text.." & vbCRLF & "It was sent using SMTP authentication."
'==This section provides the configuration information for the remote SMTP server.
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") = "mail.your.com"
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "gmxcustno"
'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "yourpassword"
'Server port (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
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update
'==End remote SMTP server configuration section==
objMessage.Send
--
and it worked
You have to check if the setting under
E-Mail-->Optionen-->Sicherheit is set to SMTP mit Login (maximale Sicherheit)
Dirk
> it took aliitle time...
>
> I had to create an acount for gmx.
At first I'd like to thank you for your dedication to this issue.
> While looking for a solution i found this very interesting page...
>
> http://www.paulsadowski.com/WSH/cdo.htm
>
> used a sample..
>
I already found that page as well, but there seemed to be no difference to
the script I used.
> and it worked
Since it worked for you, this helped me to nail down the problem.
THE SOLUTION:
Since several online tutorials used the cdoBasic variable I thought this is
a constant variable always available. But that's not the fact, one has to
define it in a script to be able to use. Once I defined/declared the variable
at the top of the script (or replaced it with a 1), the script just worked
fine.
Thank you very much!
Kind regards, Chris
Just as an FYI, this is one of the advantages afforded to Windows Script
Files (WSF) over regular VBScript Files. In a lot of objects you can add the
reference flag and the constants are automatically defined for you. Save the
below as 'example.wsf' for demonstrative purposes:
<job>
<object id="objEmail" progid="CDO.Message" reference="true"/>
<script language="VBScript">
MsgBox cdoBasic
</script>
</job>
Sometimes it is difficult to find the values for obscure named constants.
VBScript can give you a list and/or execute 'CONST constant = whatever'
statements for every constant known to the object's typelib. To find a
short script that demonstrates this, type the following into
groups.google.com's search box:
"oConstant.name" group:*.scripting.vbscript
Note that you may have to download and install a Microsoft DLL.
-Paul Randall