473,549 Members | 2,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Email not sending from Include file

1 New Member
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(userI D, 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 975

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

Similar topics

4
26671
by: Wald | last post by:
Hello group, I've got a script here that sends emails with an attachment to an email address that is retrieved from an html form. The email sending code is include below. The problem: when sending the email to certain email servers, the attachment section of the email gets removed and I end up with an attachment of zero kb. Other servers...
3
7031
by: Paul Lamonby | last post by:
Hi, I am sending a file from the server as an email attachment. The file is being attached no problem and sending the email, but I get an error when I try to open it saying it is corrupt. Obviuosly, the file is fine on the server, so the attachment code I am using must be corrupting it, but I dont know what it is: // send email with...
4
2957
by: Francois Keyeux | last post by:
hello everyone: i have a web site built using vbasic active server scripting running on iis (it works on either iis 50 and 60, but is designed for iis 50) i know how to create a plain text email by creating a text file, with content following certain format, and saving that file into the correct '..\mailroot\pickup' folder, and it is...
5
2610
by: BaWork | last post by:
I have a web form where a client can select which site members to send an email to. This form is populated from the contents of the member table, so the form can have 0-x names listed on it depending on member expiration dates. When the form is submitted, the code loops through the form contents and sends an email to those members that...
1
2995
by: Michael McGarrigle | last post by:
I would like to send the contents of a file using xp_sendmail however I do not want the file contents to be an attachment. I have no problem sending the file as an attachement. Can anybody give me an xp_sendmail example of how to do this. The results of a query can easily appear in the body of the email but all my attempts to include the...
9
3012
by: Sandy | last post by:
can mfc application, send text data to opened notepad file in desktop?(live transfer of data) . can anybody help
5
2144
by: ibid | last post by:
hi every one just wondering if anyone could help sorry if i seem abit dumb but im a newbie to it all ive got to asign a mail program on my auction site in the config.pl files (i think this is the problem)but im not sure how as i have tryed a couple of things and dont seem to be getting any where the problem is that its just not sending any...
9
4918
by: =?Utf-8?B?QW5kcmV3?= | last post by:
Hi, I want to delete my email attachment after sending the email. How do I get around this issue ? I have set up a method to send email using SMTP. public bool CreateMessageWithAttachment() { MailMessage message = new MailMessage(); ....
2
2605
by: MyWaterloo | last post by:
I have a database that I’ve created for creating/printing/sending purchase orders. It works great! Long live Access! Although, I have a slight problem with the sending part. I have a table for my suppliers that I pull some of the fields from to include in my main form for creating the purchase order. One of the fields is an email field that I...
0
7532
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7462
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7730
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7975
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7492
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6059
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5101
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3491
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1957
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.