473,748 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with Email Sending

39 New Member
Hi

I have to send mail right away when I click a button. For this I have given the coding as


Dim ob As Object
Dim ob1 As Object
Dim con As SqlConnection
Dim cmd As SqlCommand
Dim str As String
Dim rd As SqlDataReader
str = "user id=sa;password= cast;database=H ello_Dr;server= AURORA-SERVER"
con = New SqlConnection(s tr)
Try
con.Open()
Catch
End Try
str = "select UserId,Password 1 from CustomerRegistr ation2 where EmailId='" & Trim(txtEmailId .Text.ToString( )) & "' "
cmd = New SqlCommand(str, con)
rd = cmd.ExecuteRead er()
While (rd.Read())
ob = rd.GetValue(1). ToString()
ob1 = rd.GetValue(2). ToString()

End While
Dim cnt As Int16
cnt = cmd.ExecuteScal ar()
If cnt <= 0 Then
Response.Write( "Un authorise user")
Else
Dim msg As New Net.Mail.MailMe ssage("importan t.project@gmail .com", txtEmailId.Text , "Re: Info", "User Id=ob Password=ob1")
Dim mySmtp As New Net.Mail.SmtpCl ient("IP ADDRESS")
Try
mySmtp.Send(msg )
Label1.Text = "Mail Sent"
Catch ex As Exception
Label3.Text = ex.Message
Label4.Text = ex.InnerExcepti on.Message
End Try
End If
con.Close()

End Sub


If I do this, the following error is appearing


"There is already an open DataReader associated with this Command which must be closed first."


The project like if I click the Forget Password button, it should ask for the email id, check in database, retrive the userid & password , and send the user id & password to the corresponding email.
May 24 '08 #1
1 1000
kenobewan
4,871 Recognized Expert Specialist
You can't do an execute reader follow by an scalar. Close the con after reading, open another and create a new command. Not sure why you open the con in try catch but execute out of it. Also try using rdr.hasrows instead of cnt. HTH.
May 24 '08 #2

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

Similar topics

3
5872
by: Serge Myrand | last post by:
Hi everybody, The following code for sending email (found on msn I think) works find when used in a .VBS file. I double click the file and the mail is send. When I use the same code in my .ASP application I get the following message: "The pickup directory path is required and was not specified" Where to specify that directory?
2
3150
by: Eric Timely | last post by:
After a trust with exchange server established the xp_SendMail gives the following error: xp_sendmail: failed with mail error 0x80070005 Prior to the trust everything worked fine. I have tried the following: 1)Checking SQL and SQLAgents accounts all match up with default mail profile.
6
2054
by: Mike the Canadian | last post by:
I am having a very strange problem sending email with php. I have two domains. I can send an email to one domain using php but not the other. If I put both email addresses in the mail command only the one email will arrive. I can send emails the traditional way to the problem domain and they arrive fine. Is there anything that might explain this? _______ Free Windows Clipboard Utility http://www.clipboardmagic.com/
3
6831
by: VB Programmer | last post by:
I have an ASPX page where I send out emails through my mail server mail.MyDomain.com. When I send emails to MyName@MyDomain.com it sends PERFECTLY. When I try sending an email to any other address (non-MyDomain.com address) I get the following error: The server rejected one or more recipient addresses. The server response was: 550 You must check your mail from this IP or SMTP Auth before sending to BSmith@Juno.com Here's the FULL...
5
4885
by: Mark A. Sam | last post by:
Hello, I am sending two emails from the same procedure, one to myself (while testing) and another (a comfirmation) to the user on the website. I was having difficulty finding a relay server to SMTP though, but was able to do this though one of my personal account, Cabbage.Org. It doesn't make any sense to me why this works and no other account, including localhost and the remote server which hosts the website. Here is a code snippet...
2
5752
abdoelmasry
by: abdoelmasry | last post by:
Hi men i have big problem with microsoft exchange server 2003 i installed exchange server as main mail server to use it on in company i have static real ip address im sending and receiving mails good but
3
2139
crystal2005
by: crystal2005 | last post by:
I found such eror message when i tried to test sending email. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /www/110mb.com/h/e/a/v/e/n/t/u/heaventure/htdocs/send_contact.php on line 10 Do we have to set something on the hosting server in order to be able to send message?? This is my code that i encountered the problem
28
4429
tdw
by: tdw | last post by:
Hi all, I am trying to add a feature to our database that automates sending emails. When entering a new order, I want the option to send an email to the company the order came from, attaching a copy of our work order. The file that I want to attach is a rich text document created by Access and stored on our server. The creation of this document is not the problem. The problem is getting the email option to work. It does not seem to...
5
3593
by: wktarin | last post by:
Hi. I'm a relative newcomer to the world of php, and I keep bumping into a problem with a mail () form. I need to send an automatic email to two addresses, but I can't seem to get it to work. One email address works just fine, but I can't get the email sent to two different addresses no matter what I try. Below is my code. If someone could help me spot my errors, I'd appreciate it. Thanks! Code from actual page: <?php //Check if the form...
0
1569
Dormilich
by: Dormilich | last post by:
this is a follow-up thread to this one. http://bytes.com/topic/html-css/answers/863662-form-not-submitted-sometimes I figured out that the mail sending class triggers the described error. unfortunately, no error message is given by the system. <?php class Mail_Tabelle extends Mail_DB { protected $description = false; const TBL_HEAD = ' <thead>
0
9528
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9359
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9310
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9236
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6792
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6072
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3298
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
2
2774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.