473,670 Members | 2,599 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 1291
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
4478
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 current window. I have a cgi script provided by my web host to send the contents of the form through email but they only show me how to use the cgi script to send email through the submit event of the form. ie. <form name="downloadform"...
1
5336
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 works except that I have two warning nuisances: 1) Program is trying to access email Addresses you have stored in Outlook. Allow access for ... 2) A program is trying to automatically send email on your behalf ... Heck, I am only trying to a send...
9
4302
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, VisualStudio2002, VB as programing language. Our test/development version of the web app as hosted on our "localhost" works fine; our "Default SMTP Virtual Server" is running (per the IIS console).
2
2334
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 server response was: 550 5.7.1 Unable to relay for ........" now I tried to add username and password for the server to relay but it is still not working. this is the example i used:
3
4550
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 windows application it worked fine, however I need to use a service as I don't want to rely on a user being logged in. The errors I get are: Index #:System.Web.HttpException: Could not access 'CDO.Message' object. --->...
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... is it possible ?
3
9738
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 and please help. Thanks in advance. Hugh
16
4738
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 environment: VS2005 + XP.-- I have disabled firewall hardware enviornmnet:telcom's modem connects hub,hub connects two computers.。-- I also tried to connect computer to modem directly,but I can
0
1732
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 created a page called profile_sendemail.php which contains the form to send the email and here is the code: <?php // Start_session, check if user is logged in or not, and connect to the database all in one included file...
1
3005
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 documents now i want to add when admin approve/reject any documents then respective document name and the value which admin select (like approve /reject ) send to his/her mail ... previously i send mail using sepearte form through code is
0
8468
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8386
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8901
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...
1
8591
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
8660
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...
0
7415
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4209
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4390
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2799
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.