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

Home Posts Topics Members FAQ

problem with smtp mail sending

44 New Member
Hi

I have the normal server and not the SMTP service installed. I need to send a mail once if I click a button. Can anybody help me regarding that
May 13 '08 #1
9 1720
DrBunchman
979 Recognized Expert Contributor
Hi sweatha,

You will need to do one of the following:

Specify the name or IP address of a mail server in your code

or

Install the Default SMTP Server on your IIS. You can find it in the Add/Remove Programs, Add Components section of the Control Panel.

There is an article on the code required for sending mail here which may help you and this website has some useful tips for configuring your mail object further.

Let me know how you get on

Dr B
May 13 '08 #2
sweatha
44 New Member
Hi sweatha,

You will need to do one of the following:

Specify the name or IP address of a mail server in your code

or

Install the Default SMTP Server on your IIS. You can find it in the Add/Remove Programs, Add Components section of the Control Panel.

There is an article on the code required for sending mail here which may help you and this website has some useful tips for configuring your mail object further.

Let me know how you get on

Dr B
Yes I installed. Thank You...
May 13 '08 #3
sweatha
44 New Member
Hi

By getting the emailId from "txtTo"-TextBox and by clicking the button, I should send the email to the emailId which is in the txtTo-TextBox. For that I have given the code as

Imports System
Imports System.Net
Imports System.Web.Mail
Imports System.Net.Mail

Partial Class Default3
Inherits System.Web.UI.P age
Protected Sub Button1_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles Button1.Click
Try

Dim emailTitle As String = "My Email Title"
Dim emailMessage As Net.Mail.MailMe ssage
Dim body As String = "This will appear in the body of my email"
emailMessage = New Net.Mail.MailMe ssage("importan t.project@gmail .com", "txtTo", emailTitle, body)
Dim mailClient As New Net.Mail.SmtpCl ient("urlOfEmai lService.com", 25)
mailClient.Send (emailMessage)

Catch ex As Exception
End Try
End Sub

End Class


If I run the project, it is not showing any error but the mail is not getting sent.
May 13 '08 #4
Plater
7,872 Recognized Expert Expert
*merged*

Moderator
May 13 '08 #5
Curtis Rutland
3,256 Recognized Expert Specialist
Well, you won't show any error if you use a Try Catch block, and don't do anything with the Exception.

Change your code to this:
Expand|Select|Wrap|Line Numbers
  1.   Catch ex As Exception
  2.     MsgBox(ex.Message)
  3. End Try
  4.  
Then you will get a popup about your exception, if there is one.

Also, make sure that the sender address you chose is whitelisted on the receiver's email. You might be successfully sending mail, but being blocked or sent to junk mail.

Hi

By getting the emailId from "txtTo"-TextBox and by clicking the button, I should send the email to the emailId which is in the txtTo-TextBox. For that I have given the code as

Imports System
Imports System.Net
Imports System.Web.Mail
Imports System.Net.Mail

Partial Class Default3
Inherits System.Web.UI.P age
Protected Sub Button1_Click(B yVal sender As Object, ByVal e As System.EventArg s) Handles Button1.Click
Try

Dim emailTitle As String = "My Email Title"
Dim emailMessage As Net.Mail.MailMe ssage
Dim body As String = "This will appear in the body of my email"
emailMessage = New Net.Mail.MailMe ssage("importan t.project@gmail .com", "txtTo", emailTitle, body)
Dim mailClient As New Net.Mail.SmtpCl ient("urlOfEmai lService.com", 25)
mailClient.Send (emailMessage)

Catch ex As Exception
End Try
End Sub

End Class


If I run the project, it is not showing any error but the mail is not getting sent.
May 13 '08 #6
sweatha
44 New Member
Hi

Through smtp I have to send email by getting the "To"-Email Id from textbox named txtTo. For that I have given the coding as

Expand|Select|Wrap|Line Numbers
  1. Imports System
  2. Imports System.Net
  3. Imports System.Web.Mail
  4. Imports System.Net.Mail
  5.  
  6. Partial Class Default3
  7.     Inherits System.Web.UI.Page
  8.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  9.  
  10.  
  11.     End Sub
  12.  
  13.  
  14.     Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  15.         Dim msg As New Net.Mail.MailMessage("important.project@gmail.com", txtTo.Text, "Re: Hello", "Hello Friend")
  16.         Dim mySmtp As New Net.Mail.SmtpClient("IP ADDRESS")
  17.         Try
  18.             mySmtp.Send(msg)
  19.             Label1.Text = "Mail Sent"
  20.         Catch ex As Exception
  21.             Label1.Text = ex.Message
  22.         End Try
  23.     End Sub
  24.  
  25. End Class
But once I run the project it shows the error message (on Label1) as

"Failure sending mail."
---------------------------------------------------
I have already given my issue under the topic "Problem with email sending". But just now I have changed my coding in the above manner.
May 14 '08 #7
DrBunchman
979 Recognized Expert Contributor
I think you'll probably find that you have McAfee of something similar blocking your smtp from sending mail. Have you got a virus scanner or firewall running on this server?

Dr B

P.S. Please remember to use the code tags (the # button) to surround your code blocks as it makes your posts much easier to read. Thanks.
May 14 '08 #8
Plater
7,872 Recognized Expert Expert
sweatha, I have once again merged your threads on smtp email troubles.
Please DO NOT continue to double post your questions, it's against the posting guidelines.

MODERATOR


That being said, *many* smtp servers will reject/deny the sending of emails from a user until they have verified their login credentials. In your code you appear to not send user credentials so the SMTP might be rejecting it based on that.
May 14 '08 #9
Curtis Rutland
3,256 Recognized Expert Specialist
.....
Expand|Select|Wrap|Line Numbers
  1.         Try
  2.             mySmtp.Send(msg)
  3.             Label1.Text = "Mail Sent"
  4.         Catch ex As Exception
  5.             Label1.Text = ex.Message
  6.         End Try
  7.     End Sub
  8.  
  9. End Class
But once I run the project it shows the error message (on Label1) as

"Failure sending mail."
...
OK, that exception wasn't very detailed.

Adding another label (Label2) and adding this code into your Catch block:
Expand|Select|Wrap|Line Numbers
  1. Label2.Text = ex.InnerException.Message
  2.  
So if there is another, more descriptive message, you can trace it.

Other than that, you probably have an issue external to your program blocking you.
May 14 '08 #10

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

Similar topics

15
3064
by: Steven Burn | last post by:
My server has POP but only has SMTP if sending to my domain, and not other domains (such as hotmail). I'm therefore wondering, if anyone knows of any scripts etc, that will allow me to have a sort of "virtual" SMTP server on my site?. (I really can't afford to use a third party SMTP mailer). -- Regards Steven Burn
3
5566
by: dale zhang | last post by:
Hi, I write an asp.net web application. It has a “Contact Us” page, where users fill in their email, subject and text and hit send. Then the email will go to my hard coded yahoo email account. I was using optimum online service with smtp server as “mail.optonline.net”. I can receive email correctly. Now I switch to verizon DSL. I change my smtp server accordingly as
5
4881
by: Mark A. Sam | last post by:
Hello, I am sending two emails from the same procedure, one to myself (while testing) and another (a comfirmation) to the user on the website. I was having difficulty finding a relay server to SMTP though, but was able to do this though one of my personal account, Cabbage.Org. It doesn't make any sense to me why this works and no other account, including localhost and the remote server which hosts the website. Here is a code snippet...
4
6109
by: k.visube | last post by:
In my ASP application,i need to send a formatted text mail (i.e with newline characters). here in my application i used a function in javascript which construts the mail body sample snippet strbody=strbody +"dear customer,\n"; strbody=strbody +"we are glad to see ur response\n"; strbody=strbody +"we will make the needful thing as early as possible\n";
7
2384
by: Santosh | last post by:
Dear all, i am wrtiing following code for the sending email from the my asp application when i am working on the local machine i will work fine ans send email on the mentioned address. but when i deploy it on the server it doen not work. and also does not give any error. MailMessage newMessage = new MailMessage(); newMessage.From =txtEmail.Text.Trim(); newMessage.To="santosh.shinde@vritti.co.in";...
2
1815
by: softbreeze | last post by:
Operating systems: Windows 2003 Enterprise ASP.Net 2.0, IIS 6.0, *** SMTP is not installed *** I have a corporate network that has an SMTP server (10.254.3.30) on it. I have a subnet (10.5.42.0) that is part of the total corporate network. I also have a private network that has my webserver (192.168.100.184) on it. The 10.5.42.0 subnet and the private network are connected to a PIX firewall. To access the webserver, users on any corp...
1
5689
by: Benedict Verheyen | last post by:
Hi, i get an "Unable to relay for" when trying to send an email from within my network to an email address not on my domain. I don't understand why it says "relaying" as i'm sending from an internal domain user to an external user. Email server is exchange 2003 See this trace
5
3115
by: sui | last post by:
this is my code import sys, os, glob, datetime, time import smtplib ## Parameters for SMTP session port=587 SMTPserver= 'smtp.gmail.com' SMTPuser= '...@gmail.com' pw= 'fill in here' SENDER= SMTPuser
3
1711
by: swethak | last post by:
Hi, i placed the php in windows server 2003 manually , set the path in Environmental variables , and place the php.ini file in windows. Now php works fine in my server sytem.When i write the mail sending code and run that program mail didn't sent. in my php.ini file consists the smtp=localhost smtp_port=25 sendmail_from=me@localhost.com In my smtp settings: Internet Information Services->righclick on default virtual smtp...
0
1560
Dormilich
by: Dormilich | last post by:
this is a follow-up thread to this one. http://bytes.com/topic/html-css/answers/863662-form-not-submitted-sometimes I figured out that the mail sending class triggers the described error. unfortunately, no error message is given by the system. <?php class Mail_Tabelle extends Mail_DB { protected $description = false; const TBL_HEAD = ' <thead>
0
8384
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8302
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
8820
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...
0
8718
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...
0
8601
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...
1
6162
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
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
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1601
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.