469,914 Members | 2,501 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,914 developers. It's quick & easy.

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 6185
> 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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Siegfried Weiss | last post: by
7 posts views Thread by teddarr | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.