473,387 Members | 3,750 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,387 software developers and data experts.

CDO.Message parameter problem

I am trying to send mail from my ASP app using CDO, my
problem is this.

If I use a string in the .To field ie "me@myco.com" the
page works fine and the mail is sent, if I change the
value to be the result of a recordset the page fails.

I have used a response.write to check the recorset
contains a valid email address, this appears to be fine.

My code is listed below.

Dim iMsg
Dim iConf
Dim Flds
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Const cdoSendUsingPort = 2
Set Flds = iConf.Fields
With Flds
.Item
("http://schemas.microsoft.com/cdo/configuration/sendusing"
) = cdoSendUsingPort
.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserver
") = "localhost"
.Item
("http://schemas.microsoft.com/cdo/configuration/smtpconnec
tiontimeout") = 10
.Update
End With

'lookup users email address
set myRecordSet = myUser.getUserEmailAddress(Request.form
("cboAssignTo"))
emailto = myRecordSet(0)
emailTitle = "Email Alert"
emailFrom = "al***@iHotdesk.com"
sBody = "Call Description: xxxxxx " & vbcr

With iMsg
Set .Configuration = iConf
.To = emailto
.From = emailFrom
.Subject = emailTitle
.TEXTBody = sBody
.Send
End With

Any help greatfully appreciated.

Thanks
Jul 19 '05 #1
12 6388
> value to be the result of a recordset the page fails.

Could you be a little more specific?

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #2
"Paul" <pa********@ihotdesk.com> wrote in message
news:08****************************@phx.gbl...
I am trying to send mail from my ASP app using CDO, my
problem is this.

If I use a string in the .To field ie "me@myco.com" the
page works fine and the mail is sent, if I change the
value to be the result of a recordset the page fails.


Are you sure that the smtp server you are using will relay mail to external
addresses? If it's not configured to relay it may accept mail for a local
domain but reject remote domains.

Tony
Jul 19 '05 #3
Aaron

in the code I perfrom a lookup on the selected users email address
before sending the mail as follows:
----------------------------------------
'lookup users email address
set myRecordSet = myUser.getUserEmailAddress(Request.form
("cboAssignTo"))
emailto = myRecordSet(0)
------------------------------------------
This returns the users email address, however if I set the .To field as
follows:

.To = emailto

The page fails, however if I set

.To = "an****@abc.com"

it works. The recordset is poplated with an email address, I have used
response.write to verify the contents.

The wierdest thing though is that I can use the contents as the from
address (.From = emailto) without any problems.

Regards,

Paul


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #4
You still haven't answered the question.
The page fails,


I got that. What on earth does "fails" mean? Do you get an error
message??? If so, don't you think it might be useful to include it?

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #5
Is it possible there is an extra space coming from the db??

Try checking the length of the string to make sure it is what you expect
Len() and use Trim() to remove any if there are extra.

Long shot I know.

Mike
"Paul" <an*******@discussions.microsoft.com> wrote in message
news:0c****************************@phx.gbl...

Tony,

the server is sending mail without any problems, if I set
the contents of the .TO field as follows
.TO = "jo********@abc.com"
it works fine yet if I use
.To = emailto it does not work even though emailto is
pouplated with a valid email address.

I have been doing some other testing and have also found
it works ok for the .From field (.From = emailto) but not
the .To field.



-----Original Message-----
"Paul" <pa********@ihotdesk.com> wrote in message
news:08****************************@phx.gbl...
I am trying to send mail from my ASP app using CDO, my
problem is this.

If I use a string in the .To field ie "me@myco.com" the
page works fine and the mail is sent, if I change the
value to be the result of a recordset the page fails.


Are you sure that the smtp server you are using will

relay mail to external
addresses? If it's not configured to relay it may accept

mail for a local
domain but reject remote domains.

Tony
.

Jul 19 '05 #6
Thanks Mike,

tried len() and it checks out ok, I've also tried removing leading and
trailing spaces and also tried using cstr() but still no joy.
P


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #7
> still no joy.

Are we on a mission to be as vague as possible?

What do the statements "fails" and "no joy" mean???

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #8
Aaron,
when the page is working it posts back to itself (i.e. when I set the
.TO = "an****@abc.com") when it fails all I receive is a HTTP 500 -
Internal server error.

I've chedked the event logs and IIS logs but can;t find anything, I've
also switched debugging on and set the 'Send details ASP error messages
to client' option to ON in IIS but still can;t get any meaningfull
errors.

P

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #9
> when it fails all I receive is a HTTP 500 - Internal server error.

Ah, a light bulb must have gone somewhere! Hooray! Do you see why it's
difficult to proceed when the only description you give is, "it's broken"?

Now, let's find out what the real error is. http://www.aspfaq.com/2109

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #10
How about doing a ....
Response.Write emailto & "<BR>"
Response.Flush

Right after you set that value, I'll bet that it's an invalid email address.

"Paul" <pa********@ihotdesk.com> wrote in message
news:08****************************@phx.gbl...
I am trying to send mail from my ASP app using CDO, my
problem is this.

If I use a string in the .To field ie "me@myco.com" the
page works fine and the mail is sent, if I change the
value to be the result of a recordset the page fails.

I have used a response.write to check the recorset
contains a valid email address, this appears to be fine.

My code is listed below.

Dim iMsg
Dim iConf
Dim Flds
set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Const cdoSendUsingPort = 2
Set Flds = iConf.Fields
With Flds
.Item
("http://schemas.microsoft.com/cdo/configuration/sendusing"
) = cdoSendUsingPort
.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserver
") = "localhost"
.Item
("http://schemas.microsoft.com/cdo/configuration/smtpconnec
tiontimeout") = 10
.Update
End With

'lookup users email address
set myRecordSet = myUser.getUserEmailAddress(Request.form
("cboAssignTo"))
emailto = myRecordSet(0)
emailTitle = "Email Alert"
emailFrom = "al***@iHotdesk.com"
sBody = "Call Description: xxxxxx " & vbcr

With iMsg
Set .Configuration = iConf
.To = emailto
.From = emailFrom
.Subject = emailTitle
.TEXTBody = sBody
.Send
End With

Any help greatfully appreciated.

Thanks

Jul 19 '05 #11

Aaron,
when I submit the page with the TO field populated with the contents of
my recordset I get a HTTP 500 error, when I submit the page and
substitute the recordset contents for "me@atmycompany.com" the page
submits and an email is sent to me. I can;t be more specific than that.

I have tried populating the .FROM field with the contents of the
recordset and this works (I receive an email with the from field set to
the correct address). What I can;t work out is why I can't use the
value from my recordset in the TO field yet I can use it in the FROM
field.

I may sound like I'm being vague but IIS is not helping matters by only
giving me a HTTP 500 error.

P

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #12
> I may sound like I'm being vague but IIS is not helping matters by only
giving me a HTTP 500 error.


That is your BROWSER causing that, not IIS. See my other reply.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dan | last post by:
I've run into an interesting problem, and seemed to have stumped 3 newsgroups and 2 other forums. For some reason when I try to insert a record into a SQL table that has a Text column, the...
3
by: WGW | last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost! everything I need. Maybe not efficiently, but usefully. However, I have a problem -- a complex query problem... I can...
9
by: Simon | last post by:
Hi everyone, I'm wondering what you're supposed to do when you call a method that is required to perform some action but that action subsequently fails. More specifically, how do you get a...
6
by: ndn_24_7 | last post by:
Hello all, I have a stored procedure that prompts the user for beginning date and ending date to run a monthly report. The prompt says Enter_Beginning_Date and Enter_Ending_Date. I want the prompt...
4
by: wkaras | last post by:
I would like to propose the following changes to the C++ Standard, the goal of which are to provide an improved ability to specify the constraints on type parameters to templates. Let me say from...
2
by: Siegfried Weiss | last post by:
Hi guys, i give up finding a solution by reading or by trial & error. Hope, YOU can help me! (Sorry for my rather long posting.) Stroustrup says, that templates could be declared with - type...
1
by: Clark Choi | last post by:
I ran the sample application called Petstore from msdn. Everything went fine until I tested Update button on the web form to update the database through Datagrid. I have been searching the web to...
2
by: paul.dunstone | last post by:
HI all I am using msbuild to compile my web application project. After building the solution I get the following error message: Server Error in '/Community' Application....
7
by: teddarr | last post by:
I have an assignment I've been working on for a few days now. I need some help with the last detail. The program is supposed to create 5 objects with varying floating-point parameter lists. The...
8
by: DanicaDear | last post by:
I have something interesting...looking to see if anyone else has came across this. I have a query with parameter and and the query works beautifully every time. However, when I use the wizard...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.