472,131 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,131 software developers and data experts.

Email not sending from Include file

Using ASPEmail can send mail to an account on my server and external emails. However, I have 2 functions that call the same sendEmail function from an include page to send mail external. For some reason 1 function works OK, but the other doesn't. Am baffled.

Added response.writes on the calling page, all looks ok. mail not getting sent. as follows:

join.asp calls SendEmail(userID, subject, body) function via include file:

Expand|Select|Wrap|Line Numbers
  1.    1.
  2.  
  3.    2.
  4.       '//Send confirmation to new member;
  5.    3.
  6.           oDB.SendEMail rs.Fields("UserID"), "Welcome to Lovebay.co.uk!", _
  7.    4.
  8.               "Hi " & rs.Fields("Forenames") & "!" & _
  9.    5.
  10.               vbcrlf & vbcrlf & _
  11.    6.
  12.               "Thank you for joining lovebay.  This email contains your username and password, just in case you forget it later on." & _
  13.    7.
  14.               vbcrlf & vbcrlf & _
  15.    8.
  16.               "Username: " & rs.Fields("Username") & vbcrlf & _
  17.    9.
  18.               "Password: " & rs.Fields("Password") & _
  19.   10.
  20.               vbcrlf & vbcrlf & _
  21.   11.
  22.               "You're a very valuable member, we hope you find what you're looking for!"
  23.   12.
  24.  
  25.   13.
  26.                '//test code
  27.   14.
  28.                   Response.Write rs.Fields("UserID") & "=>Join3 b4email send" & vbCRLF
  29.   15.
  30.                   Response.Write rs.Fields("Username") & "=>Join3 b4" & vbCRLF 
  31.  
/include/sendemail.asp:

Expand|Select|Wrap|Line Numbers
  1.    2.
  2.       Public Function SendEMail(ToUserID, Subject, Body)
  3.    3.
  4.               Dim cnn
  5.    4.
  6.               Dim SQL
  7.    5.
  8.               Dim rs
  9.    6.
  10.               Dim bOK
  11.    7.
  12.               Dim oMail
  13.    8.
  14.               Dim sName
  15.    9.
  16.               Dim sEMail
  17.   10.
  18.               Set cnn = Connect
  19.   11.
  20.  
  21.   12.
  22.                '//test code - OK response here
  23.   13.
  24.                   Response.Write ToUserID & ":just enter SendEmail!"
  25.   14.
  26.                   Response.Write Subject & ":just enter SendEmail!"
  27.   15.
  28.                   Response.Write Body & ":just enter SendEmail!"
  29.   16.
  30.  
  31.   17.
  32.               If ToUserID = -999 Then
  33.   18.
  34.               sName = "me"
  35.   19.
  36.               sEMail = "some@email.com"
  37.   20.
  38.  
  39.   21.
  40.               Else
  41.   22.
  42.                   SQL = "SELECT users details From aTable WHERE UsersID = " & ToUserID
  43.   23.
  44.  
  45.   24.
  46.                   Set rs = Server.CreateObject("ADODB.Recordset")
  47.   25.
  48.                   rs.Open SQL,cnn,3,1
  49.   26.
  50.                   If rs.EOF Then
  51.   27.
  52.                       Exit Function
  53.   28.
  54.  
  55.   29.
  56.               Else
  57.   30.
  58.                   sName = rs.Fields("Forenames")
  59.   31.
  60.                   sEMail = rs.Fields("EMail")
  61.   32.
  62.                   rs.Close
  63.   33.
  64.  
  65.   34.
  66.                   End If
  67.   35.
  68.  
  69.   36.
  70.               End If      
  71.   37.
  72.  
  73.   38.
  74.                   '//test code
  75.   39.
  76.                   Response.Write ToUserID & "b4email send" & vbCRLF
  77.   40.
  78.                   Response.Write sEmail & "b4" & vbCRLF
  79.   41.
  80.  
  81.   42.
  82.               '//Send E-Mail;
  83.   43.
  84.                   Set oMail = Server.CreateObject("Persits.MailSender")           
  85.   44.
  86.                   oMail.FromName = "Lovebay"
  87.   45.
  88.                   oMail.From = "email@mydomain.com"
  89.   46.
  90.                   oMail.Host = "smtp.myhost.com"
  91.   47.
  92.                   oMail.AddAddress sEmail, sName
  93.   48.
  94.                   oMail.Subject = Subject
  95.   49.
  96.                   oMail.Body = Body & GetSig
  97.   50.
  98.                   If oMail.Send Then
  99.   51.
  100.                       bOK = True
  101.   52.
  102.                   Else
  103.   53.
  104.                   bOK = False
  105.   54.
  106.                   End If
  107.   55.
  108.                   oMail.ResetAll
  109.   56.
  110.                   Set oMail = Nothing
  111.   57.
  112.               SendEMail = True
  113.   58.
  114.           End Function 
  115.  
When this code is called from a different page, it works. But when called from the joinUp.asp page, not getting any email, but the response.writes seem ok.

????
Apr 2 '07 #1
0 951

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Wald | last post: by
3 posts views Thread by Paul Lamonby | last post: by
5 posts views Thread by ibid | last post: by
9 posts views Thread by =?Utf-8?B?QW5kcmV3?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.