By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,290 Members | 1,253 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,290 IT Pros & Developers. It's quick & easy.

Problem with CDO.configuration

P: n/a
Hi all,
I am sending mail from my apps with CDO nowadays.
However I have one client where this will not work until now.
I am thinking this is related to the provider where the client has his internet-account.

I am using cdosys with 'late binding'. I try to send mail with an attachment to a few mailaddresses (strTo)
The *exact same code* (with other smtpserver-login and pw strings) does work on various other PC's with various other providers.

The code:
SendCDOMail "Subject... " & Format(Date, "dd-mm-yyyy"), msg, strTo, "C:\svb\output.html"

Sub SendCDOMail(strSubject, strBody, strTo, strAttach)
On Error GoTo Err_SendCDOMail
Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2 'Must use this to use Delivery Notification
Const cdoAnonymous = 0
Const cdoBasic = 1 ' clear text
Const cdoNTLM = 2 'NTLM
'Delivery Status Notifications
Const cdoDSNDefault = 0 'None
Const cdoDSNNever = 1 'None
Const cdoDSNFailure = 2 'Failure
Const cdoDSNSuccess = 4 'Success
Const cdoDSNDelay = 8 'Delay
Const cdoDSNSuccessFailOrDelay = 14 'Success, failure or delay

Dim objMsg As Object
Dim objConf As Object
Dim objFlds As Object

Set objMsg = CreateObject("CDO.Message")
Set objConf = CreateObject("CDO.Configuration")

Set objFlds = objConf.Fields
With objFlds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpserver here"
..Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "account here"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password here"
.Update
End With

With objMsg
Set .Configuration = objConf
.To = strTo
.Subject = strSubject
.cc = bl*@test.nl
.From = blabl*@test.nl
.TextBody = strBody
.AddAttachment strAttach
.DSNOptions = cdoDSNFailure
.Fields.Update
.Send
End With
Exit Sub

Err_SendCDOMail:
MsgBox Err & " " & Error$, vbCritical, TITEL
End Sub

Thanks for any ideas...
Arno R
Jun 14 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"Arno R" <ar****************@planet.nlwrote in
news:46***********************@text.nova.planet.nl :
Hi all,
I am sending mail from my apps with CDO nowadays.
However I have one client where this will not work until now.
I am thinking this is related to the provider where the client has his
internet-account.
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername")
= "account here"
.From = bl****@test.nl
Some smtp servers seem to require that "account here" and bl****@test.nl be
the same string. I beleve one can avoid this difficulty in general by
omitting the the line

..From = bl****@test.nl

in which case FROM will default to
sendusername
but it's been a long time since I wrote code that used CDO, and I may be
recalling things that never happened.

--
lyle fairfield
Jun 14 '07 #2

P: n/a

"lyle fairfield" <ly******@yahoo.caschreef in bericht news:Rt******************@read1.cgocable.net...
"Arno R" <ar****************@planet.nlwrote in
news:46***********************@text.nova.planet.nl :
>Hi all,
I am sending mail from my apps with CDO nowadays.
However I have one client where this will not work until now.
I am thinking this is related to the provider where the client has his
internet-account.
> ..Item("http://schemas.microsoft.com/cdo/configuration/sendusername")
= "account here"
> .From = bl****@test.nl
Some smtp servers seem to require that "account here" and bl****@test.nl be
the same string. I beleve one can avoid this difficulty in general by
omitting the the line

.From = bl****@test.nl

in which case FROM will default to
sendusername
but it's been a long time since I wrote code that used CDO, and I may be
recalling things that never happened.

--
lyle fairfield
Hi Lyle,
How are you doing these days???

The answer you give might be very true. I will check that tomorrow at the clients office.
This particular ISP is very restictive indeed.

Arno R
Jun 14 '07 #3

P: n/a

"lyle fairfield" <ly******@yahoo.caschreef in bericht news:Rt******************@read1.cgocable.net...
"Arno R" <ar****************@planet.nlwrote in
news:46***********************@text.nova.planet.nl :
>Hi all,
I am sending mail from my apps with CDO nowadays.
However I have one client where this will not work until now.
I am thinking this is related to the provider where the client has his
internet-account.
> ..Item("http://schemas.microsoft.com/cdo/configuration/sendusername")
= "account here"
> .From = bl****@test.nl
Some smtp servers seem to require that "account here" and bl****@test.nl be
the same string. I beleve one can avoid this difficulty in general by
omitting the the line

.From = bl****@test.nl

in which case FROM will default to
sendusername
but it's been a long time since I wrote code that used CDO, and I may be
recalling things that never happened.

--
lyle fairfield
Hi Lyle,

I went to the client this afternoon with a modified mde. Alas: Stil no mail sending....
Your solution seemed very promising to me, but apparently this was/is not wat causes the problem.
So I also mailed the techsupport at the ISP with this problem.
I got an automated mai back like "bla bla....... very busy at the moment...... ".
But they "will come back shortly...." Hmmm...I don't have the time to wait for that...

Must be a 'stupid' property somewhere I guess...

Any other ideas ?? Anyone ??
Any free smtp-servers available ??

Arno R
Jun 15 '07 #4

P: n/a

"lyle fairfield" <ly******@yahoo.caschreef in bericht news:Rt******************@read1.cgocable.net...
"Arno R" <ar****************@planet.nlwrote in
news:46***********************@text.nova.planet.nl :
>Hi all,
I am sending mail from my apps with CDO nowadays.
However I have one client where this will not work until now.
I am thinking this is related to the provider where the client has his
internet-account.
> ..Item("http://schemas.microsoft.com/cdo/configuration/sendusername")
= "account here"
> .From = bl****@test.nl
Some smtp servers seem to require that "account here" and bl****@test.nl be
the same string. I beleve one can avoid this difficulty in general by
omitting the the line

.From = bl****@test.nl

in which case FROM will default to
sendusername
but it's been a long time since I wrote code that used CDO, and I may be
recalling things that never happened.

--
lyle fairfield
Unfortunately the above solution did not work so...
To (try to) solve my problem I created a gmail-account and I tried to use gmail as external smtp-server.
(I found some info o that by Googling)
I came across the initial errormessages by using port 465 and a ssl connection like in :

with objFields
....
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 455
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = "true"
end with
BUT.... still no mail has been send ?????

Any ideas ??
I am at lost here !!

Arno R
Jun 16 '07 #5

P: n/a
Arno R wrote:
"lyle fairfield" <ly******@yahoo.caschreef in bericht news:Rt******************@read1.cgocable.net...
>"Arno R" <ar****************@planet.nlwrote in
news:46***********************@text.nova.planet.n l:
>>Hi all,
I am sending mail from my apps with CDO nowadays.
However I have one client where this will not work until now.
I am thinking this is related to the provider where the client has his
internet-account.
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername")
= "account here"
.From = bl****@test.nl
Some smtp servers seem to require that "account here" and bl****@test.nl be
the same string. I beleve one can avoid this difficulty in general by
omitting the the line

.From = bl****@test.nl

in which case FROM will default to
sendusername
but it's been a long time since I wrote code that used CDO, and I may be
recalling things that never happened.

--
lyle fairfield

Unfortunately the above solution did not work so...
To (try to) solve my problem I created a gmail-account and I tried to use gmail as external smtp-server.
(I found some info o that by Googling)
I came across the initial errormessages by using port 465 and a ssl connection like in :

with objFields
...
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 455
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = "true"
end with
smtpusessl takes a true/false value not a string. Here is some *working*
code I've used. Note that some lines might wrap:

'------------------
' --- CDO Defines (e.g. using GMAIL) :

Private Const cdoSendUsingPickup = 1 'Send message using the local SMTP
service pickup directory.
Private Const cdoSendUsingPort = 2 'Send the message using the network
(SMTP over the network).

Private Const cdoAnonymous = 0 'Do not authenticate
Private Const cdoBasic = 1 ' basic (clear-text) authentication
Private Const cdoNTLM = 2 ' NTLM

Private Const cdoMailSMTP_Server As String = "smtp.gmail.com"
Private Const cdoMailSMTP_Port As Long = 465

Public Function sendCDO_Mail(sTo As String, sSubject As String, sMsg As
String) As Boolean
On Error GoTo errHandler

Dim objMessage As Object, sUserID As String, sPassword As String

sUserID = Nz(DLookup("[cdoMailUserID]", "tblSettings"), "") '
set your user id here
sPassword = Nz(DLookup("[cdoMailPassword]", "tblSettings"), "") '
set your password here

If Len(sUserID) 0 Then
Set objMessage = CreateObject("CDO.Message")

With objMessage
.Subject = sSubject
.From = sUserID ' required field
.To = sTo
.TextBody = sMsg

'==This section provides the configuration information for
the remote SMTP server.

..Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2

' Name or IP of Remote SMTP Server

..Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
= cdoMailSMTP_Server

' Type of authentication, NONE, Basic (Base64 encoded), NTLM

..Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")
= cdoBasic

' Your UserID on the SMTP server

..Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername")
= sUserID

' Your password on the SMTP server

..Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword")
= sPassword

' Server port (typically 25) - gmail uses 587 or 465

..Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= cdoMailSMTP_Port

' Use SSL for the connection (False or True)

..Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl")
= True

'Connection Timeout in seconds (the maximum time CDO will
try to establish a connection to the SMTP server)

..Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout")
= 180

.Configuration.Fields.Update
'==End remote SMTP server configuration section==

.Send

sendCDO_Mail = True
End With
End If

Exit Function

errHandler:

Dim nErr As Long, sErr As String
nErr = Err.Number
sErr = Err.Description

Debug.Print "Error in sendCDO_Mail: " & nErr & " - " & sErr

End Function
'------------------------

Good luck!

--
'--------------------------
' John Mishefske
' UtterAccess Editor
' 2007 Microsoft Access MVP
'--------------------------
Jun 17 '07 #6

P: n/a
Hi John,

Thanks a million for your code !!
Because of that code I was able to figure out what was wrong in my code.
smtpusessl takes a true/false value not a string. Here is some *working*
code I've used. Note that some lines might wrap:
Indeed "true" should not be a string but should be the value 'True'.
It actually was the value True, because I was using code like MailOption("SSL") for that option which was returning a boolean value.
For simplicity reasons I posted 'wrong' code.... :-(

But your code worked, and mine did not, so I was able to find the offending code!
What was wrong?
It appeared that the line .DSNOptions = cdoDSNFailure (or ..DSNOptions = 2) was causing the trouble!
When I omitted that line everything was OK.
Including this line (also in your code) results in mail not being delivered.

So problem solved !
Thanks again!

Arno R
Jun 17 '07 #7

P: n/a
Arno R wrote:
Hi John,

Thanks a million for your code !!
Because of that code I was able to figure out what was wrong in my code.
Glad I could help.
It appeared that the line .DSNOptions = cdoDSNFailure (or .DSNOptions = 2) was causing the trouble!
When I omitted that line everything was OK.
That is for Delivery Status Notification. Here is some additional info
if readers are interested:

http://support.microsoft.com/kb/302839
--
'--------------------------
' John Mishefske
' UtterAccess Editor
' 2007 Microsoft Access MVP
'--------------------------
Jun 17 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.