473,513 Members | 2,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to send email in asp.net vb.net

62 New Member
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 1288
Frinavale
9,735 Recognized Expert Moderator Expert
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
4458
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
5321
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
4293
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
2331
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
4537
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
336
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
9727
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
4699
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
1724
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
2994
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
7260
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,...
1
7099
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
7525
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
5685
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,...
1
5086
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...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
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 ...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.