473,395 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Sending User Name & Password thru Email

39
Hi

By getting the email id from txtEmailId, I have to send the user name & password to that particular email id. For that on button click event I have given the coding as
Expand|Select|Wrap|Line Numbers
  1.  
  2. Protected Sub imgSend_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgSend.Click
  3.  
  4. If txtEmailId.Text = "" Then
  5. WebMsgBox.Show("Please enter your email address and try again.")
  6. End If
  7.  
  8.  
  9. Dim ob As String
  10. Dim ob1 As String
  11. Dim con As SqlConnection
  12. Dim cmd As SqlCommand
  13. Dim str, str1 As String
  14. Dim rd As SqlDataReader
  15. str = "user id=sa;password=cast;database=jsc;server=AURORA-SERVER"
  16. con = New SqlConnection(str)
  17. Try
  18. con.Open()
  19. Catch
  20. End Try
  21. str1 = "select loginid,password from login where email='" & Trim(txtEmailId.Text.ToString()) & "' "
  22. cmd = New SqlCommand(str1, con)
  23. rd = cmd.ExecuteReader()
  24. While (rd.Read())
  25. ob = rd.GetValue(1).ToString()
  26. ob1 = rd.GetValue(2).ToString()
  27.  
  28. End While
  29. Dim cnt As Int16
  30. cnt = cmd.ExecuteScalar()
  31. If cnt <= 0 Then
  32. WebMsgBox.Show("The email address you entered does not match our records. Please check your entry and try again.")
  33. Else
  34. Dim msg As New Net.Mail.MailMessage("important.project@gmail.com", txtEmailId.Text, "Re: Info", "User Id='" & ob & "' Password='" & ob1 & "'")
  35. Dim mySmtp As New Net.Mail.SmtpClient("IP ADDRESS")
  36. Try
  37. mySmtp.Send(msg)
  38. Label1.Text = "Mail Sent"
  39. Catch ex As Exception
  40. Label2.Text = ex.Message
  41. Label1.Text = ex.InnerException.Message
  42. End Try
  43. End If
  44. con.Close()
  45. End Sub
  46.  
  47. Here I have retrived the user name & password from database, stored it in a variable & used the variables in the line as 
  48.  
  49. Net.Mail.MailMessage("important.project@gmail.com", txtEmailId.Text, "Re: Info", "User Id='" & ob & "' Password='" & ob1 & "'")
  50.  
  51. Instead of passing the variable ob,ob1 as 
  52. "User Id='" & ob & "' Password='" & ob1 & "'"
  53.  
is there any other way to pass those variable.
Jun 11 '08 #1
4 1674
r035198x
13,262 8TB
Your approach looks OK (to me). Any reason why don't want to pass the parameters like that?
Jun 11 '08 #2
vijayB
40
Your approach looks OK (to me). Any reason why don't want to pass the parameters like that?

I think this link will help you;

http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx
Jun 11 '08 #3
suganya
39
Dim msg As New Net.Mail.MailMessage("important.project@gmail.com" , txtEmailId.Text, "Re: Info", "User Id='" & ob & "' Password='" & ob1 & "'")

In the above line I have specified the

Message body- it should be simply specified in "".
All that we entered inside the "" are considered simply as a text.So if I enter the user name & password DB values then it consider it (" & ob & "') also as the text that is inside.
Jun 11 '08 #4
r035198x
13,262 8TB
Dim msg As New Net.Mail.MailMessage("important.project@gmail.com" , txtEmailId.Text, "Re: Info", "User Id='" & ob & "' Password='" & ob1 & "'")

In the above line I have specified the

Message body- it should be simply specified in "".
All that we entered inside the "" are considered simply as a text.So if I enter the user name & password DB values then it consider it (" & ob & "') also as the text that is inside.
What is the user Id and password supposed to be for?
The MailMessage class certainly doesn't need them.
Jun 11 '08 #5

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

Similar topics

4
by: Allan Hugo | last post by:
Not a programmin newbie, but a PHP newbie. I'm working off the user authentication and database thing off hotscripts.com. It doesn't work, yet from what I can see, it should. Maybe I've...
5
by: Ken Nistler | last post by:
Hello, I was wondering if anyone can help me out. I am trying to send mail from a c# app thru my ISP pop3 mail server. I figured it would be similar to using SMTP, but use my username and...
3
by: Ivan Weiss | last post by:
I have an application where employees fill out forms and they are e-mailed to the responsibility party once completed. I was planning on using Microsoft Outlook (since everyone uses it for office...
4
by: splicemix | last post by:
Hi all, I have recently set up a Drupal website. I am a beginner. My shared host server does not allow nobody@localhost to send emails, and prevents access to php.ini, so I spent some time...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
1
by: GoneRural | last post by:
Hello, I am trying to figure out how can I run a process under the authenticated user's credentials without having to prompt for a username and password? Is there anyway to allow for pass thru...
1
by: kang jia | last post by:
hi when user entered particulars in signuppage and click" signup" button, i will direct them to do_signup.php. if say the NRIC is dupicate in datebase, i will redirect them back to signup page...
2
by: Allie | last post by:
Hi, all. I'm new to C# programming. I'm even newer to programming email capabilities into my code. What I need to do is create three (3) functions: * sendEmail, using a Mail object (which needs...
0
by: trivedimca2005 | last post by:
I am using below code for sending Email using .net. Its not working on client machine. My server IP is:- 192.168.10.10 and also uses proxy and user-name and password for proxy settings are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...

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.