473,378 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Problem with CDO.configuration

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
7 7247
"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

"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

"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

"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Maxim | last post by:
If there is a document like this: <Configurations> <Configuration default="true"> ... </Configuration> <Configuration> ...
0
by: M. v.d. Bogaard | last post by:
Hi, I am trying to publish some custom Publisher Exceptions using the Exception Management Building Block. When an exception is thrown my application crashes and I get the following error in the...
0
by: HakonB | last post by:
Hi all I get an exception when trying to deserialize a simple configuration file using XML Serialization. The very long stacktrace can be seen at the bottom of this message. I've see other...
1
by: Dave | last post by:
Hello I hves some problem in my Web.conficg file. The problem is following: I have created some custom settings in this way: ============================================== <!-- Define handlers...
0
by: Jorgas | last post by:
Hi! I try to use the configuration application block from the Enterprise Library and have done prework as specified from one of the hands-on labs from that package. When trying to get...
3
by: Bratislav Jevtic | last post by:
Hi, I've just installed Ajax November CTP, changed app according to instructions and I am (was) satisfied. Next step - deployment to server. I'm receiving error:...
2
by: shapper | last post by:
Hello, I have a contact form in my web site which is working just fine on my computer! When I uploaded my web site to my hosting server I get an error when I SUBMIT my form, i.e., when I...
7
by: Santosh | last post by:
Dear all, i am wrtiing following code for the sending email from the my asp application when i am working on the local machine i will work fine ans send email on the mentioned address. but when i...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I cut and paste the following code from msdn help page which it just introduces view and multiview server controls. Here is what I do: in vs studio 2005, File --New Web Site, it...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.