Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Send email using CDOSYS

Posted on 2003-11-11
14
Medium Priority
?
2,054 Views
Last Modified: 2008-02-01
I can't seem to make this work and I am not sure what I am doing wrong.

<%
Dim iMsg
Set iMsg = CreateObject("CDO.Message")
Dim iBp
Dim Flds

Dim iConf
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
Flds(cdoSendUsingMethod)  = cdoSendUsingPort
Flds(cdoSMTPServer)       = "smtp.beap.com"
Flds(cdoSMTPServerPort)   = 25
Flds(cdoSMTPAuthenticate)     = cdoAnonymous ' 0
Flds.Update

With iMsg
  Set .Configuration = iConf
    .To          = "me@mydomain.com"
    .From        = "me@mydomain.com"
    .Sender      = "me2@mydomain.com"
    .Subject     = "Partner information change request"
    .TextBody    = "This is a test.<br>This is still a test." + vbLfCr + vbLfCr

    .Send
End With
%>

The code is from Microsofts site.

I am getting this error:
     ADODB.Fields error '800a0bb9'
     Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
     /test.asp, line 36


Line 36 is: Flds(cdoSendUsingMethod)  = cdoSendUsingPort
0
Comment
Question by:lpenrod
  • 7
  • 4
  • 2
  • +1
14 Comments
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 9723674
> Set iMsg = CreateObject("CDO.Message")

maybe try

Set iMsg = Server.CreateObject("CDO.Message")
0
 
LVL 3

Author Comment

by:lpenrod
ID: 9723759
No change.
0
 
LVL 3

Author Comment

by:lpenrod
ID: 9723968
Not sure if it is relevant.  The box is a Windows 2003 server running IIS6.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Accepted Solution

by:
barryfandango earned 2000 total points
ID: 9723970
adilkhan,

It could be that the vb constants you're using aren't in the local scope.  Try adding these two lines to the very top of your file, if they're not already there:

<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->


Note that these go _outside_ of your server-side code <% %>.
0
 
LVL 3

Author Comment

by:lpenrod
ID: 9724015
That did it.

The points are yours, thanks!

For bonus points, do you know how to make it so I can send HTML code in the body?
0
 
LVL 3

Assisted Solution

by:barryfandango
barryfandango earned 2000 total points
ID: 9724050
You should be able to just set iMsg.HTMLBody to a string containing your HTML, like this:

With iMsg
  Set .Configuration = iConf
    .To          = "me@mydomain.com"
    .From        = "me@mydomain.com"
    .Sender      = "me2@mydomain.com"
    .Subject     = "Partner information change request"
    .TextBody    = "This is the text body."
    .HTMLBody = "<html><body><p>This is the HTML Body.</p></body></html>"
    .Send
End With

- make sure you always include a text body as some mailreaders won't display html, and some users don't want it.

- make sure HTMLBody is a well-formed html document, not just a string with html formatting (see example.)
0
 
LVL 3

Author Comment

by:lpenrod
ID: 9724089
You rock!
0
 
LVL 23

Expert Comment

by:Saqib Khan
ID: 9724108
barryfandango so we can use this method to send email VIA win XP as well?
by adding the Library?
0
 
LVL 3

Expert Comment

by:barryfandango
ID: 9724124
Yes, xp (pro) supports CDOSYS.  I think it even has it installed by default, but don't quote me on that.  So if your IIS is running on XP this should work (it works on my end.)
0
 
LVL 3

Author Comment

by:lpenrod
ID: 9724133
I have a question also if you know regarding the line:  Flds(cdoSMTPAuthenticate)     = cdoAnonymous ' 0

To prevent relaying, you have to be authenticated or on our internal private network.  Does this mean that if someone tried this from home it would fail since they are not on the internal private network?
0
 
LVL 3

Expert Comment

by:barryfandango
ID: 9724156
That depends what you mean.  If your web-user was based from home, the server-side code is still running on your internal network (your IIS machine is doing the job.)  If the home user had IIS and was trying to execute this script then you could possibly encounter that problem.
0
 
LVL 3

Author Comment

by:lpenrod
ID: 9724173
Got you.  I forgot that the IIS server running the code is internal and therefore would be allowed to send mail.

Thanks again!
0
 

Expert Comment

by:andiwebx
ID: 10442363
the script workws fine for me, as long as i use the email address that lives on the server.. i have a form that sends an emial to the address you enter into the form, . if for example the site is www.sitename.com/, the asp page will send an email to  test@sitename.com, but not for test@othersitename.com.

i know it is something wrong with the STMP server, right?
0
 
LVL 3

Author Comment

by:lpenrod
ID: 10443196
Relay restriction?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Loops Section Overview

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question