Invalid procedure call or argument

Posted on 2007-10-05
Last Modified: 2008-06-25
I'm getting this error when I test this code. Can anyone tell me what is the problem here?

thank you!

<!--#include virtual="/public_includes/dbConnect.asp"-->
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<!--#include virtual="/public_includes/javascript_misc.asp"-->
<!--#include virtual="/public_includes/header3.htm"-->
<!--#include virtual="/public_includes/Misc.asp"-->
<!--#include virtual="upload.asp"-->
<body onload="DoLoad()">
On Error resume next
      Dim Uploader, File
      Set Uploader = New FileUploader            
                  ' This starts the upload process
            FileDestination = Server.MapPath("..") & "\NewsLetters"

                  ' This starts the upload process
                  If Uploader.Files.Count <> 0 Then

                  ' Loop through the uploaded files
                        For Each File In Uploader.Files.Items
                              ' Save the file
                              File.SaveToDisk FileDestination
                              ' Get the file name
                              FileName = File.FileName
                        If err.number <> 0 then
                           response.write err.number & " - " & err.description
                        end if
                        'Get email list            
                        q_str =  "SELECT distinct email from tblNLSubscriber"
                        Set rs = oConn.Execute(q_str)  
                        if Not rs.EOF then
                              toStr = ""
                              i = 0
                              do while not rs.eof
                                 i = i + 1
                                 toStr = toStr & rs("email") & ";"
                        end if
                        rs.close ()

body=uploader.form("MailBody") &"<html><p>&nbsp;</p><p><a href='http://"&Request.ServerVariables("SERVER_NAME")&"/emailUnSubscribe.asp'>Click Here</a> to Un-Subscribe</html>"

                        ' Send Attachment                        
                              Dim objMessage

                              Set objMessage = Server.CreateObject("CDONTS.Newmail")

                              With objMessage
                                    ' Set message attributes
                                    .To       = ""
                                    .From     = "IRAP_Intranet"
                                    .BCC        = toStr
                                    .Subject  = "IRAP Connection Newsletter"
                                    .MailFormat = 0      '0=Mime format, 1=default plain text format
                                    .BodyFormat = 0      '0=HTML format, 1=default plain text format
                                    .Body = body
'                                    .TextBody = Uploader.form("MailBody")

                                    ' Attachment using known static physical path
                                    '.AddAttachment "c:\somepath\somefile.txt"

                                    ' Attachment using mappath to find the physical path
                                    .AttachFile Server.MapPath("/NewsLetters/" & FileName & "")

                                    ' Attachment added directly from a URL
                                    '.AddAttachment ""
                              End With

                        Set objMessage = Nothing
                        if err.number <> 0 then
                                 response.write "Error occured.  Newsletter are not being sent.  Please contact the webmaster.<br>"
                                 response.write "Error: " & err.number & " - " & err.description
                                 response.write "Thank you.  The Quarterly News Letter has been sent.<p><a href='webadmin.asp'>Back to Web Admin page</a>"
                        end if                        
                        response.write "No Newsletter attached.  Messages are not being sent."
                  End If

set rs = nothing
set oConn = nothing

<!--#include virtual="/public_includes/footer.htm"-->
Question by:Platini
    LVL 30

    Expert Comment

    did the browser told you where the line number of the error is? try commenting 'On Error resume next' first, the line number will give you a hint.
    LVL 30

    Expert Comment

    i mean error line number.

    Author Comment

    it said error code 5
    LVL 30

    Accepted Solution

    that error code doesn't help that much. I guess you have a problem on sending emails. try to replace your code with this below,

    Set objMessage = Server.CreateObject("CDO.Message")

    With objMessage
          ' Set message attributes
          .To       = ""
          .From     = "IRAP_Intranet"
          .BCC        = toStr
          .Subject  = "IRAP Connection Newsletter"
          .HTMLBody = body

          ' Attachment using known static physical path
          '.AddAttachment "c:\somepath\somefile.txt"

          ' Attachment using mappath to find the physical path
          .AttachFile Server.MapPath("/NewsLetters/" & FileName & "")

    End With

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    758 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now