Link to home
Start Free TrialLog in
Avatar of raj_ms
raj_ms

asked on

Please help its urgent. cdo sendusing configuration value is invalid

Dim val1 As String, val3 As String, val4 As String, val5 As String
Dim email As String
Dim from_mail As String
Dim Mail_Body As String
Dim mmcdoconfig As Cdo.Configuration
Dim mgcdomsg As Cdo.Message
Dim an As New ADODB.Connection
Dim ar As New ADODB.Recordset
Dim hn As New ADODB.Recordset

Private Sub Send_Mail(from_mail As String)

Set mmcdoconfig = New Cdo.Configuration
Set mgcdomsg = New Cdo.Message
Set ar = an.Execute("select * from d4d.customer where type=1")
Set hn = an.Execute("select * from raj.htmls")
'mgcdomsg.DSNOptions = cdoDSNDefault
mmcdoconfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = CdoSendUsing.cdoSendUsingPort
mmcdoconfig.Fields("Smtpserver") = "smtp.hotpop.com"
mmcdoconfig.Fields("smtpserverport") = 25
mmcdoconfig.Fields("Username") = "userid@HotPOP.com"
mmcdoconfig.Fields("Password") = "passsword"
mmcdoconfig.Fields("SendemailAddress") = emailadress
mgcdomsg.Subject = subject
mgcdomsg.MimeFormatted = True

mmcdoconfig.Load (cdoIIS)
mgcdomsg.Configuration = mmcdoconfig
If Not hn.EOF Then
    mgcdomsg.HTMLBody = hn.Fields(1).Value 'html body from database
End If
'While Not ar.EOF
   ' mgcdomsg.Sender = ar.Fields(2)
    mgcdomsg.To = "emailadress"
    mgcdomsg.From = fromaddress
   
    mgcdomsg.Send
    Sleep (10)
'    ar.MoveNext
'Wend

Command1.Enabled = False

End Sub
Public Sub Sleep(ByVal duration As Integer)
  Dim x As Integer
  For x = 1 To duration * 1000
       DoEvents
  Next x
End Sub


when i run this code there is a runtime error 80040220 which says the "SendUsing configuration value is invalid.
i am using the remote smtp. i have uninstalled the local smtp  in my machine

ASKER CERTIFIED SOLUTION
Avatar of rinksno1
rinksno1

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of raj_ms
raj_ms

ASKER

rinks,
it again uses local smtp, instead of my remote smtp.
i tried to uninstall smtp also.
Avatar of raj_ms

ASKER

even after uninstalling it uses my local smtp
Avatar of raj_ms

ASKER

Set objMessage.Configuration = objConfig
there is an error
it gave an error (0x8004020F) near this line
Avatar of raj_ms

ASKER

this error is by asp
Avatar of raj_ms

ASKER

Can you please help me sort out this error. its ok if it is asp also.
Avatar of raj_ms

ASKER

<html>
<head>
</head>
<body>
<%
Const cdoSendUsingMethod       = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort          = 2
Const cdoSMTPServer             = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort         = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout  = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate       = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic                  = 1
Const cdoSendUserName           = "http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword           = "http://schemas.microsoft.com/cdo/configuration/sendpassword"

Dim objConfig  ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields     ' As ADODB.Fields

' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set objMessage = Server.CreateObject("CDO.Message")
Set Fields = objConfig.Fields

' Set config fields we care about
With Fields
     .Item(cdoSendUsingMethod)       = cdoSendUsingPort
     .Item(cdoSMTPServer)            = "smtp.hotpop.com"
     .Item(cdoSMTPServerPort)        = 25
     .Item(cdoSMTPConnectionTimeout) = 60
     .Item(cdoSMTPAuthenticate)      = cdoBasic
     .Item(cdoSendUserName)          = "raj_itengg@HotPop.com"          
     .Item(cdoSendPassword)          = "abcdef1"

     .Update
End With

Set objMessage.Configuration = objConfig

With objMessage
     .mimeformatted=true
     .To       = "emailid"
     .From     = "senderaddress"
     .Subject  = "SMTP "
     .HtmlBody = "<html><head></head><body>SMTP Relay Test Sent @ " & Now() & "</body></html>"
     .Send
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
%>

</body>
</html>

this gives error as below


HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

--------------------------------------------------------------------------------

Technical Information (for support personnel)

Error Type:
(0x8004020F)
/remotesmtpmail.asp, line 46


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)

Page:
POST 13 bytes to /remotesmtpmail.asp
Avatar of raj_ms

ASKER

Now mails are not going since i switched off the local smtp and giving the error.

HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services

--------------------------------------------------------------------------------

Technical Information (for support personnel)

Error Type:
(0x8004020F)
/remotesmtpmail.asp, line 46


Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)

Page:
POST 13 bytes to /remotesmtpmail.asp

even if i switch on the local smtp, it porduces the same error.
Avatar of raj_ms

ASKER

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY><PRE><%
Const cdoBasic = 1 'Use basic (clear-text) authentication.
Const cdoSendUsingPort = 2

Dim iMsg
Dim iConf
Dim Flds

On Error Resume Next

'Create message and configuration objects
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.Fields

'Appluy settings to the configuration object
With Flds
      ' Specify the authentication mechanism to basic (clear-text) authentication.
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
      ' The username for authenticating to an SMTP server
'      .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "MAIL_SMTP_USERNAME"

      ' The password used to authenticate to an SMTP server
'      .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "MAIL_SMTP_PASSWORD"

      .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort

      'Specify mail server
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "10.10.1.23 "'"MAIL_SMTP_SERVER"

      'Specify the timeout in seconds
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = "30"

      ' The port on which the SMTP service specified by the smtpserver field is listening for connections (typically 25)
      .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
      
      'Use SSL for the connection (False or True)
      '.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False

      .Update
End With

Dim sMsg
Dim sTo
Dim sCC
Dim sFrom
Dim sSubject
Dim sTextBody

sTo = "someid@hotmail.com"

sFrom = "someid@hotmail.com"
sSubject = "Insert here your subject text"
sTextBody = "Insert here your plain body text"

'Apply the settings to the message object
With iMsg
      Set .Configuration = iConf
        .mimeformatted=false
      .To = sTo
      .From = sFrom
      
      .Subject = sSubject
      .TextBody = sTextBody
      
      'Send message
      .Send
      
End With

      if err.number=0 then
            response.write "Mails Sent"
      end if
' cleanup mail objects
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing

%></PRE></BODY></HTML>


this code doesnot give any errors, but mails are not going

My smtp server is a lotus domino and have top level domin as uk and sub domain as co
Avatar of raj_ms

ASKER

<html>
<head>
</head>
<body>
<%
Const cdoSendUsingMethod       = "http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSendUsingPort          = 2
Const cdoSMTPServer             = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPort         = "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
Const cdoSMTPConnectionTimeout  = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
Const cdoSMTPAuthenticate       = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
Const cdoBasic                  = 1
Const cdoSendUserName           = "http://schemas.microsoft.com/cdo/configuration/sendusername"
Const cdoSendPassword           = "http://schemas.microsoft.com/cdo/configuration/sendpassword"

Dim objConfig  ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields     ' As ADODB.Fields

' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set objMessage = Server.CreateObject("CDO.Message")
Set Fields = objConfig.Fields

' Set config fields we care about
With Fields
     .Item(cdoSendUsingMethod)       = cdoSendUsingPort
     .Item(cdoSMTPServer)            = "10.10.1.23" '"smtp.hotpop.com"
     .Item(cdoSMTPServerPort)        = 25
     .Item(cdoSMTPConnectionTimeout) = 60
     .Item(cdoSMTPAuthenticate)      = cdoBasic
 '    .Item(cdoSendUserName)          = "raj_itengg@HotPop.com"          
 '    .Item(cdoSendPassword)          = "abcdef1"

     .Update
End With

'Set objMessage.Configuration = objConfig

With objMessage
     .mimeformatted=true
     .To       = "address@hotmail.com"
     .From     = "address"
     .Subject  = "SMTP "
     .HtmlBody = "<html><head></head><body>SMTP Relay Test Sent @ " & Now() & "</body></html>"
     .Send
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
%>

</body>
</html>

this code is one that gave me an error. but the error is rectified by commenting a statement
'Set objMessage.Configuration = objConfig
but the problem still exists. mails are not moving from pickup folder, i am not using local smtp.
have you tried asp email this can be used to relay from a defined smtp server....

www.aspemail.com

rinks
in case you are under firewall/proxy if yes you might need some settings at the proxy server also....

rinks
Avatar of raj_ms

ASKER

i got it myself but its with an intuition and ur help instead of const i used "http://schemas.microsoft.com/cdo/configuration/" so it worked


Set mmcdoconfig = New Cdo.Configuration
Set mgcdomsg = New Cdo.Message
mmcdoconfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'CdoSendUsing.cdoSendUsingPort
'mgcdomsg.DSNOptions = cdoDSNDefault
mmcdoconfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "jeeves"   '"smtp.hotpop.com"
mmcdoconfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'mmcdoconfig.Fields("smtpauthenticate") = cdoBasic
'mmcdoconfig.Fields("sendusername") = "dajkaj"
'mmcdoconfig.Fields("sendpassword") = "password"
mmcdoconfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
mmcdoconfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendemailaddress") = adrdes
mmcdoconfig.Fields.Update
mgcdomsg.Subject = val5
mgcdomsg.MimeFormatted = True

mmcdoconfig.Load (cdoIIS)
Set mgcdomsg.Configuration = mmcdoconfig
    mgcdomsg.HTMLBody = "<html<head></head><body>hello</body></html>" 'hn.Fields(1).Value
    mgcdomsg.To = "raj_itengg@hotmail.com" '"arumugaraja.mohan@unitednetworks.co.uk"
    mgcdomsg.From = val3 '"Dial4discount<info@dial4discount.com>" 'val5
   
    mgcdomsg.Send
    Sleep (10)