473,657 Members | 2,555 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help for a Simple Email App using ASP/SMTP

49 New Member
I'm working on a simple web app to send email. Below is my code:

Expand|Select|Wrap|Line Numbers
  1. Imports System.Net.Mail
  2. Partial Class _Default
  3.     Inherits System.Web.UI.Page
  4.  
  5.     Protected Sub SubmitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SubmitButton.Click
  6.  
  7.         Dim FromAddress As String = "mturner64@student.se.edu"
  8.  
  9.         'Create the MailMessage instance
  10.         Dim email As New System.Net.Mail.MailMessage(FromAddress, ToTextBox.Text)
  11.  
  12.         'Assign the MailMessage's properties
  13.         email.Subject = SubjectTextBox.Text
  14.         email.Body = BodyTextBox.Text
  15.         email.IsBodyHtml = False
  16.  
  17.         'add attachment
  18.         email.Attachments.Add(New Attachment(FileUpload1.PostedFile.InputStream, FileUpload1.FileName))
  19.  
  20.         'Create the SmtpClient object
  21.         Dim smtp As New SmtpClient
  22.  
  23.         'Send the MailMessage (will use the Web.config settings)
  24.         smtp.Send(email)
  25.         smtp.Host = "mail.se.edu"
  26.  
  27.  
  28.     End Sub
I have added the following code to my webconfig file:

Expand|Select|Wrap|Line Numbers
  1. <system.net>
  2.     <mailSettings>
  3.       <smtp from="mturner64@student.se.edu">
  4.         <network host="mail.se.edu"/>
  5.       </smtp>
  6.     </mailSettings>
  7.   </system.net>

The error I get is as follows:

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 164.58.120.84:2 5

WHAT TO DO?
May 5 '08 #1
3 1429
DrBunchman
979 Recognized Expert Contributor
Hi mturner64,

Firstly, you've posted this in the ASP forum which is for Classic ASP only. I'm moved the thread to the .NET forum where you should receive better help.

As for your question, the problem here is probably the connection to your mail host. I'm not 100% sure about this one but you might need to set the Host property of your smtp object before using the Send method.

Also, can you try pinging that host name from the machine which hosts your web pages? It could be a problem with the DNS resolving the name - have you tried using the IP address of your mail server instead?

Dr B
May 6 '08 #2
Plater
7,872 Recognized Expert Expert
What errors are you getting? The SMTP server should send you an error code and possibly a short message describing the error.

You need to make sure you have a few things first:
1) Does you email host allow smtp connections?
2) Do you have the correct hostname for the smtp server?
3) Does your SMTP host require authentication to send mail (most do)?
May 6 '08 #3
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
i think you might want to swap these 2 lines
Expand|Select|Wrap|Line Numbers
  1. 'Send the MailMessage (will use the Web.config settings)
  2. smtp.Send(email)
  3. smtp.Host = "mail.se.edu"
and make it
Expand|Select|Wrap|Line Numbers
  1. 'Send the MailMessage (will use the Web.config settings)
  2. smtp.Host = "mail.se.edu"
  3. smtp.Send(email)
though this wouldnt help much as you already speified the settings in the config file
May 7 '08 #4

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

Similar topics

0
9870
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ********************************** package Celcom.Client;
1
1846
by: StevenBarnes | last post by:
I need to have some .Net code be able to send Email using my ISP's SMTP server. I found some articles on how to use the MAIL FROM: and RCPT TO: commands that you can stream to a tcp connection on port 25 of the mail server. Works nice, but I can only send Emails to addresses on the same domain as mine (I'm me@myhost.net. I can send to you@myhost.net, but not myfriend@someotherprovider.com). I get a code back from the RCPT TO: command of...
19
2784
by: Bill | last post by:
I have searched through the posts for a question like mine but have only found much more complicated responses. On single record view of a form I have an email address field. I merely want to create a button that will email the same message (and idealy a word attachment) to whatever address is in view on the form (chances are that I just input it). For further explanation:
5
2495
by: Charlie | last post by:
Hi: I'm working on an e-commerce site. Using the SMTP class, my site sends out confirmation messages. It works most of the time, but sometimes raises an error. I need a way of making sure it goes out every time. I thought about wrapping a try-catch handler in loop that keeps on retrying if delivery fails. Is this a good idea? If not, what is the best way of handling this kind of thing? Thanks,
11
1677
by: Sehboo | last post by:
Hi, I want to write a very very simple mail application which my father can use (maybe then I will be able to send and receive emails from him). This application will have a text box, where he will type a message, and a button. Once he presses this button the application will send an email to me (my email address will be hardcoded). I don't think that it can get any simpler. Problem is that how to send email from standalone machine...
2
1217
by: Vanessa Lee | last post by:
Hello, Is it possible to write a script using CONDTS object to read all emails from the SMTP IIS "Drop" folder without changing the username and email address in LogonSMTP? or is there completely another way to do it. Here is what I want exactly the program to do: I just want to have one script that will be able to pickup and read all emails that arrive regardless of the email prefix. For example, I want the script to read:...
4
3091
by: krishnakant Mane | last post by:
hello, I am a bit confused. I want to make a program that will take some data from a database and make a string of text. and send it to the respective email id of a person. next I also want to send an attachment of a photo along with the email. I will be required to make this program run on windows xp. can some one guide me as to how I can achieve this? what I will need on windows to send emails? I believe yahoo, gmail, rediff and msn...
8
7277
by: shapper | last post by:
Hello, I am trying to send an email using Asp.Net 2.0. I am getting the following error: System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: No such user here at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify,
31
12674
by: happyse27 | last post by:
Hi All, I am trying for weeks how to send email from windows pc, which from my gmail account to my hotmail account. Using net::smtp module sending email failed,Kindly assist. (for the item d it is working for normal email servers, but NOT with gmail server, I am very puzzled still!!) Codes(item c below) It keeps complaining and logs and codes are below. a) apache access logs --------------------------------- 127.0.0.1 - - "GET...
0
8737
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
8509
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
8610
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
7345
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
4168
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
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
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
1967
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1730
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.