Frage

recently added smtp authentication to our mail server and found a very funny thing. When using a variable in the to cdomessage.to field it will come back with error '8004020f'. However if I hardcode the email address it works fine. here is my code:

varEmail = "someoneelse@somesite.com"
set cdoMessage = CreateObject("CDO.Message")
set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
    .Item(cdoSendUsingMethod) = 2
    .Item(cdoSMTPServer) = "localhost" 
    .Item(cdoSMTPServerPort) = 25 
    .Item(cdoSMTPconnectiontimeout) = 10
    .Update 
end With
CdoMessage.Configuration = cdoConfig
cdoMessage.Subject="NEW EMAIL"
cdoMessage.From="someone@somesite.com"
cdoMessage.To=varEmail
cdoMessage.TextBody="HELLO WORLD!"
cdoMessage.Send
set cdoMessage=nothing
set cdoConfig=nothing

How can I fix this so that I can use a variable in the cdoMessage.To field

War es hilfreich?

Lösung

Try:

.Item(cdoSendUsingMethod) = cdoSendUsingPickup

Edit 2015/09/14: Looks like the link I posted further info the domain has been lost, check the wayback archive: https://web.archive.org/web/20150518232254/http://classicasp.aspfaq.com/email/why-does-cdo-message-give-me-8004020f-errors.html

Also check out http://classicasp.aspfaq.com/email/why-does-cdo-message-give-me-8004020f-errors.html (NO LONGER WORKING)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top