473,404 Members | 2,137 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,404 software developers and data experts.

How to send email in asp.net vb.net

i Am using below code in vb.net to send email using smtp

Expand|Select|Wrap|Line Numbers
  1.                 Dim strmsgbody As String
  2.                 strmsgbody = "Your Login Deatils For SESS IS" & vbNewLine & "User Name:'" & TextBox1.Text & "'" & vbNewLine & "Password:" & TextBox2.Text & " '"
  3.                 Using mm As New MailMessage("rahulsankhe2310@gmail.com", txtforpassempemail.Text)
  4.                     mm.Subject = "Password Recovery Of Schindler Employee Self Service"
  5.                     mm.Body = strmsgbody
  6.  
  7.                     mm.IsBodyHtml = False
  8.                     Dim smtp As New SmtpClient()
  9.                     smtp.Host = "smtp.gmail.com"
  10.                     smtp.EnableSsl = True
  11.                     Dim NetworkCred As New NetworkCredential("senderemail.text", "senderpassword")
  12.                     smtp.UseDefaultCredentials = True
  13.                     smtp.Credentials = NetworkCred
  14.                     smtp.Port = 587
  15.                     smtp.Send(mm)
  16.                     ClientScript.RegisterStartupScript(Me.GetType, "alert", "alert('Email sent.');", True)
  17.                 End Using
  18.  
  19.                 Response.Write("<script type='text/javascript'>alert('PASSWORD ALONG WITH LOGIN DETAILS SEND TO PROVIDED EMAIL ADDRESS');</script>")
  20.                 txtforpassempcode.Text = ""
  21.                 txtforpassempemail.Text = ""
  22.                 Response.Redirect("SESSLogin.aspx", False)
  23.  
The code works well for gmail but when i change smtp name and port number of my organization smtp server anme and port 25 it gives
error "sending email failed"

Please Help
Oct 1 '14 #1
1 1283
Frinavale
9,735 Expert Mod 8TB
You need to configure your MailMessage with settings that will work for the server you are connected to.

I suggest that you investigate your mail server to determine if it uses SSL, what port etc.


-Frinny
Oct 2 '14 #2

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

Similar topics

1
by: mhawkins19 | last post by:
I have a form built and on the onclick event I validate all of the fields and then if the form is ok, on the submit event I run a javascript function to set a cookie and download a file from the...
1
by: Jay McGrath | last post by:
Help - trying to send a simple text email with with as little user intervention. I am trying to create a button in my Access application that will automatically send a simple text email. It...
9
by: Bob Jones | last post by:
We have developed a commercial ASP.net application (personal nutrition management and tracking); we want to send smtp email from within it. For our development box, we use WinXP Pro, IIS 5.5,...
2
by: Ron | last post by:
hi guys, I am trying to send email using smtpMail. I can send emails inside the organization, but out of the organization I get an error "The server rejected one or more recipient addresses. The...
3
by: Gerard | last post by:
Hello I have created a windows service to monitor a database, it starts some checks when a timer elapses. The checks send emails depending on their findings. My issue is that when I created a...
2
by: ucasesoftware | last post by:
i start a process to send email via Outlook I have succes to build the email text, objet, sender... but i want to automate the "send"... i don't want my users to click on Send email button......
3
by: =?Utf-8?B?SHVnaA==?= | last post by:
Hi There, I use follow code to send email inside VB.NET 2005. It does not work well. Error message of "Failure sending email" would occue. However, email was sent out sometimes. I am confused...
16
by: =?Utf-8?B?Q2hlZg==?= | last post by:
I can use outlook2003 to send email,but I cann't use this code below to send email. Please help me to test this code and instruct me how to solve this problem in detail. software...
0
by: Mike Massaro | last post by:
Hello everyone, I'm new to PHP and creating an advertising website for massage therapists. On the profile page I'm creating a button so anyone can click on to send the advertiser an email. I...
1
by: prita1001 | last post by:
previously i am trying to send mails in separate form like this http://i.stack.imgur.com/klLVx.png but now i want to send mail automatically in respective email address.. Admin approve/reject...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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...
0
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,...
0
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...

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.