Hi Everybody,
i have a problem with smtp server. i developed an application on my local machine and it runs fine.it uses our smtp server to send emails. but when i uploaded the app on to the server it does not send any emails although it is using the same smtp server.
our smtp server settings are definitly not an issue. anonymous access is given there is no limit on number of messages everything is fine.i dont know how is it able to work on local mahcine and not on server(even though both are using same smtp server)
did anyone face this kind of problem. please let me know if you have any ideas
Ayush
8 1390
Have you put in code to see why it is failing?
Make sure there are no Firewalls or Proxies that could be blocking emails.
Check your Windows event logs for any details about what might be failing...
In your code, put try catches in and check if emails were sent success fully...if not then record it into a log so that you can determine what the problem is.
-Frinny
Hi all,
thank you for replying.This code worked before. it sent emails but now it suddenly stopped working. there are no major changes we did to server settings. there are no firewalls and proxies. I cannot see anything in smtp log there are no details listed about the mail sent at that time. i tried sending emails from command prompt of that server and the emails went out.so i think this is not a server issue. but the code worked before i dont know whats wrong now. any ideas?
Code:(text) -
Try
-
oEmail.To = recipient
-
oEmail.Subject = subject
-
oEmail.Body = message
-
oEmail.BodyFormat = bodyFormat
-
oEmail.From = sender
-
-
oEmail.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
-
oEmail.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = hostSmtpServer
-
oEmail.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
-
oEmail.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "fgtt\ggggg"
-
oEmail.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "hghg"
-
-
SmtpMail.SmtpServer = hostSmtpServer
-
SmtpMail.Send(oEmail)
-
-
Catch
-
End Try
Record any exceptions you've encountered in your Catch block....you could write it to a text file, record it to an event log....but right now you are catching the exception and not doing anything with it.
You could remove the Try Catch block for testing purposes...when an exception is thrown it should appear in your Windows Application Event Log in this case....
i tried catching an exception but there is no exception thrown nor i can see some error in event viewer.
what is strange is i can send the emails from a command prompt from the server that my application is, using smtp server that is sending emails. but when i do the same thing from website it does not happen. so theres definitly something wrong with the code. - Public Shared Sub SendEmail(ByVal recipient As String, _
-
ByVal sender As String, _
-
ByVal subject As String, _
-
ByVal message As String, _
-
ByVal hostSmtpServer As String, _
-
Optional ByVal bodyFormat As MailFormat = MailFormat.Html)
-
-
Dim oEmail As New MailMessage
-
-
Try
-
oEmail.To = recipient
-
oEmail.Subject = subject
-
oEmail.Body = message
-
oEmail.BodyFormat = bodyFormat
-
oEmail.From = sender
-
-
oEmail.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
-
oEmail.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = hostSmtpServer
-
oEmail.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
-
-
SmtpMail.SmtpServer = hostSmtpServer
-
SmtpMail.Send(oEmail)
-
-
Catch Ex As Exception
-
Dim objStreamWriter As StreamWriter
-
objStreamWriter = File.AppendText("C:\sample.txt")
-
objStreamWriter.WriteLine(Ex)
-
objStreamWriter.Close()
-
-
End Try
-
-
End Sub
-
(Hi Frinavale,
please let me know how to add code tags i have no idea how to do that.)
Ayush
You can use the # button on the text editor to insert your opening and closing code tags.
It's like HTML with square brackets instead. [code] to open, and you close by putting a slash in between the bracket and the c: [/C
What version of .NET are you using and what namesapce are you using to create your MailMessage?
The only thing that I'm unsure of in your code is the use of the Fields property. Looking up the MailMessage control (in the System.Net.Mail namespace) I don't see a Fields property at all...I've never used this property.
Anyways, give the following code a try and see if it works.
(Please note that right now I'm unable to fully test the code so it may not work 100%) -
Public Shared sub SendEmail(ByVal recipient As String, _
-
ByVal sender As String, _
-
ByVal subject As String, _
-
ByVal message As String, _
-
ByVal hostSmtpServer As String, _
-
Optional ByVal bodyFormat As MailFormat = MailFormat.Html)
-
-
-
-
Try
-
'oEmail.To = recipient
-
'oEmail.Subject = subject
-
'oEmail.Body = message
-
'oEmail.BodyFormat = bodyFormat
-
'oEmail.From = sender
-
-
'oEmail.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
-
'oEmail.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = hostSmtpServer
-
'oEmail.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
-
oEmail= New Net.Mail.MailMessage(sender, recipient, subject, message)
-
-
-
'SmtpMail.SmtpServer = hostSmtpServer
-
'SmtpMail.Send(oEmail)
-
-
Dim mailClient As New Net.Mail.SmtpClient(hostSmtpServer, 25)
-
mailClient.Send(oEmail)
-
-
Catch Ex As Exception
-
Dim objStreamWriter As StreamWriter
-
objStreamWriter = File.AppendText("C:\sample.txt")
-
objStreamWriter.WriteLine(Ex)
-
objStreamWriter.Close()
-
-
End Try
-
-
End Sub
-
-
Also, does your mail server provider require credentials in order to send emails?
-Frinny
Hi,
I am using .NET 1.1 VS 2003. I am using "Imports System.Web.Mail" mail sever does not need credentials . I removed credentials and checked it it still doesn't send any emails.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Gerhard |
last post by:
Hi,
I some asp.net beta 2 code that works fine on an XP Pro machine, but on a
Windows 2003 Server gets the following error:
System.Net.Mail.SmtpFailedRecipientException {"Mailbox unavailable....
|
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,...
|
by: scorpion53061 |
last post by:
I would like to know how you guys are handling this issue......
Some ISP's are now requiring authentication when using SMTP (such as
orcsweb)
while others are refusing to accept plain text...
|
by: 00_DotNetWarrior |
last post by:
I followed this article to do authenticated SMTP, it works fine with port
25. (using .NET framework 1.1)
http://support.microsoft.com/default.aspx?scid=kb;en-us;555287
However, if I change the...
|
by: desais |
last post by:
I am using the cdo.dll to send out emails in C#. But instead of
connecting to my local smtp to forward the email I am changing the smtp
server to the recipients server for each email. This works...
|
by: antonyliu2002 |
last post by:
I've set up the virtual smtp server on my IIS 5.1 like so:
1. Assign IP address to "All Unassigned", and listen to port 25.
2. Access Connection granted to "127.0.0.1".
3. Relay only allow...
|
by: Benny Ng |
last post by:
Dear All,
Now I just finished my winform application. And a part of that is to
send email reminder to the users. It's working fine in the server that with
SMTP service in Windows 2003.
But now...
|
by: =?Utf-8?B?TWlrZQ==?= |
last post by:
Hi,
I'm using this code for sending emails and its working fine because I had
configured SMTP in my machine in IIS.
now I'm using machine as a server for this application. but when running the...
|
by: tamaker |
last post by:
I have Road Runner cable internet access and Im working in a local
development environment (writing .ASP) and have a site running on my
network on a windows xp pro machine via IIS with CDONTS...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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: 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,...
|
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: 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...
| |