473,396 Members | 1,724 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,396 software developers and data experts.

problem with smtp mail sending

44
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 1704
DrBunchman
979 Expert 512MB
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
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
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.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try

Dim emailTitle As String = "My Email Title"
Dim emailMessage As Net.Mail.MailMessage
Dim body As String = "This will appear in the body of my email"
emailMessage = New Net.Mail.MailMessage("important.project@gmail.com" , "txtTo", emailTitle, body)
Dim mailClient As New Net.Mail.SmtpClient("urlOfEmailService.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 Expert 4TB
*merged*

Moderator
May 13 '08 #5
Curtis Rutland
3,256 Expert 2GB
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.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Try

Dim emailTitle As String = "My Email Title"
Dim emailMessage As Net.Mail.MailMessage
Dim body As String = "This will appear in the body of my email"
emailMessage = New Net.Mail.MailMessage("important.project@gmail.com" , "txtTo", emailTitle, body)
Dim mailClient As New Net.Mail.SmtpClient("urlOfEmailService.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
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 Expert 512MB
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 Expert 4TB
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 Expert 2GB
.....
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
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...
3
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...
5
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...
4
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 ...
7
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...
2
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)...
1
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...
5
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'...
3
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...
0
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....
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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 projectplanning, coding, testing,...

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.