Results 1 to 5 of 5

Thread: how to call function in asp?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539
    sorry this is vb not asp, but i get faster responses here..
    and is vb related some how..

    here is my mail function
    Code:
    Function SendEmail( sEmailServer, sFromEmail, sToEmail, sSubject, sText )
       Dim objMail
       Set objMail = CreateObject("Persits.MailSender") 
       objMail.From = sFromEmail
       objMail.Host = sEmailServer
       objMail.AddAddress sToEmail
       objMail.Subject = sSubject
       objMail.Body = sText
       On Error Resume Next 
       objMail.Send 
       If Err <> 0 Then 
           SendEmail =  "An error occurred: " & Err.Description 
       End If
       Set objMail = nothing 
    End Function
    i have that in a file and i include it with my asp page,s
    since i dont get error including it... i assume it includes the file correctlly...

    and i try to call the function from my asp pages as follow
    Code:
    errMsg = SendEmail("lndn1.on.wave.home.com", "[email protected]", Email, "1", "1" )
    i get the following error
    Code:
    Error Type:
    Microsoft VBScript runtime (0x800A000D)
    Type mismatch: 'SendEmail'
    anyone know why? thanks

  2. #2
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    Hi,
    Not sure if it is the same in ASP but you haven't set hte function to be a type.
    I have added to your code but I don't know whether it will work in ASP!!
    Code:
    Function SendEmail( sEmailServer, sFromEmail, sToEmail, sSubject, sText ) As String
       Dim objMail
       Set objMail = CreateObject("Persits.MailSender") 
       objMail.From = sFromEmail
       objMail.Host = sEmailServer
       objMail.AddAddress sToEmail
       objMail.Subject = sSubject
       objMail.Body = sText
       On Error Resume Next 
       objMail.Send 
       If Err <> 0 Then 
           SendEmail =  "An error occurred: " & Err.Description 
       Else
           SendEmail ="OK"
       End If
       Set objMail = nothing 
    End Function
    Hope this helps

    Shaun
    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

  3. #3

  4. #4
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243
    hi,
    just a thought...is errMsg a String type variable?

    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,539

    fixed it..

    STUPID STUPID STUIPID ME

    i for got to put <% %>
    around my function
    hehe

    fixed thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width