CDO.Message parameter problem

P

Paul

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 "(e-mail address removed)" 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 = "(e-mail address removed)"
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
 
A

Aaron Bertrand - MVP

value to be the result of a recordset the page fails.

Could you be a little more specific?
 
T

Tony B

Paul said:
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 "(e-mail address removed)" 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
 
P

Paul Sells

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 = "(e-mail address removed)"

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
 
A

Aaron Bertrand - MVP

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?
 
M

Mike D

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
 
P

paul

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
 
A

Aaron Bertrand - MVP

still no joy.

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

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

paul

Aaron,


when the page is working it posts back to itself (i.e. when I set the
.TO = "(e-mail address removed)") 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
 
A

Aaron Bertrand - MVP

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
 
T

TomB

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.
 
P

paul

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 "(e-mail address removed)" 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
 
A

Aaron Bertrand - MVP

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,698
Latest member
LydiaHalle

Latest Threads

Top