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
9 1704
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
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...
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.
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: -
Catch ex As Exception
-
MsgBox(ex.Message)
-
End Try
-
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.
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 - Imports System
-
Imports System.Net
-
Imports System.Web.Mail
-
Imports System.Net.Mail
-
-
Partial Class Default3
-
Inherits System.Web.UI.Page
-
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
-
-
-
End Sub
-
-
-
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
-
Dim msg As New Net.Mail.MailMessage("important.project@gmail.com", txtTo.Text, "Re: Hello", "Hello Friend")
-
Dim mySmtp As New Net.Mail.SmtpClient("IP ADDRESS")
-
Try
-
mySmtp.Send(msg)
-
Label1.Text = "Mail Sent"
-
Catch ex As Exception
-
Label1.Text = ex.Message
-
End Try
-
End Sub
-
-
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.
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.
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.
..... -
Try
-
mySmtp.Send(msg)
-
Label1.Text = "Mail Sent"
-
Catch ex As Exception
-
Label1.Text = ex.Message
-
End Try
-
End Sub
-
-
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: -
Label2.Text = ex.InnerException.Message
-
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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
...
|
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...
|
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)...
|
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...
|
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'...
|
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...
|
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....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
| |