By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,466 Members | 1,132 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

Problem with System.Web.Mail.MailMessage

P: 2
I use Visual Studio 2003,, NetFramework 1.4 and Windows XP

I have been using the following Code Snippet for a number of years in both Web Services and Windows Applications.
However suddenly around the 29th September 2010 it has stopped sending E-Mails from both Web Services and Windows Applications.
The same problem has happened not only to my own Network but on two other Networks, one using XP as its Server anf the other using Server 2003.
All 3 of these are using different ISPs.

Imports System.Web.Mail
Dim Message As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage
Message.Body = "Whatever ..."
Message.To = "My E-Mail Address"
Message.From = "Sender's E-Mail Address"
Message.Subject = "Something ..."
SmtpMail.SmtpServer.Insert(0, " or your mail server name here")
Catch ex As Exception
End Try
End Snippet ***********
Nothing clever and it has ALWAYS worked in the past.
Now it just doesn't send anything and doesn't generate any Exception Message.

It's not (?) Machine Setup, Program change, ISP problem, Anti-Virus Program, User, etc and I am totally at a loss to explain what has happened!

There is one possible exception/reason, all the systems affected have one thing in common - Windows Update!

Has anyone else had these problems and/or has anyone any comment or suggestions?

David Smith.
Oct 11 '10 #1
Share this Question
Share on Google+
6 Replies

Expert 100+
P: 321
Are they all pointing to the same mail server which may have been an open relay but now requires authentication?
Oct 14 '10 #2

P: n/a
I'm not sure what is meant by 'all pointing to the same Mail Server'. Each of the 3 machines is on a different ISP. Each points to me as the recipient. One also points to another recipient and he doesn't get his copy.

I'm also not to sure what my 'Mail server' is.
Is it the 'Outgoing SMTP Server' hosted by my ISP?

If this is the case then I get the following: smtp

Not an open relay.
0 seconds - Good on Connection time
0.764 seconds - Good on Transaction time
OK - resolves to
OK - Reverse DNS matches SMTP Banner

The first line 'Not an open relay' looks suspicious!
Regarding the use of E-Mailing in my applications:
The principle uses are
a) to send an E-Mail to me containing the 'Exception' caught by Try/Catch if there has been an error.
b) to simply send an E-Mail, again to me, containing any comment the User wants to make. In this case one of the applications also sends an E-Mail to someone else who is using a completey different ISP.
Sorry I'm a bit vague on this but I'm a 'quick learner' when I get pointed in the right direction.

David Smith
Oct 14 '10 #3

Expert 100+
P: 321
Yes the mail server is from your ISP unless you're on a work network. In the snippet you provided, the mail server would be on this line:
Expand|Select|Wrap|Line Numbers
  1. SmtpMail.SmtpServer.Insert(0, " or your mail server name here")
I really don't see that ever working.

"Not an open relay" means you have to authenticate with the mail server.

Your application should gather the following information from the user:
SMTP Mail server (Typically from ISP or work network)
SMTP Port (Usually 25)
SMTP Username (usually their e-mail address or text before "@" in e-mail address)
SMTP Password

See this example:
Oct 15 '10 #4

P: n/a
Thanks for your reply.
Re: " or your mail server name here") - I have never understood this but all I can say is that it has always worked up until the 29th September.
Re: Gathering information from the User - I use "f2s" as my ISP and they provide an auto-configuration for MS Outlook Mail. I had a look at Control Panel>Mail>ChangeAccount and clicked the 'Test Settings' Button and it reported all as being OK.
I didn't expect otherwise because my normal Mail is working OK.
Moreover I don't know the Mail Settings for the other two Users/ISPs therefore, since it worked in the past for them, it seems that System.Web.Mail has had no problem querying 'Data Collaboration Objects' or what-have-you without any help from me.
Again, since this problem is not confined to my Machine or my ISP and that the code has worked in the past, I have to assume that either a Microsoft Update or simultaneous changes by, at least, 3 ISPs is responsible.
Of these Microsoft Updates seems the most likely cause?
Its the only thing common to all 3 Users.
I just don't know where to go or what to try!

David Smith
Oct 15 '10 #5

Expert 100+
P: 321
You are correct, your code is probably fine and a windows update has probably messed it up, it's too coincidental. Unfortunately, I am not familiar with troubleshooting issues with the SMTP service on client machines. You can either troubleshoot your issue with the SMTP service not working after windows updates, or have your program bypass local pickup and send through the mail server for each users network/ISP.

For your old code, You may want to change " or your mail server name here" to just "" or "localhost", as there were complaints of that string not being used for anything... Maybe a patch made that actually *do something* now and your string is improper.

To try it a different way you can try something like this:
Expand|Select|Wrap|Line Numbers
  1.         Public Shared Sub SendMail()
  2.             Dim smtpServer As String = ""
  3.             Dim userName As String = "johnDoe"
  4.             Dim password As String = "pass"
  5.             Dim cdoBasic As Integer = 1
  6.             Dim cdoSendUsingPort As Integer = 2
  7.             Dim msg As New MailMessage()
  8.             If userName.Length > 0 Then
  9.                 msg.Fields.Add("", smtpServer)
  10.                 msg.Fields.Add("", 25)
  11.                 msg.Fields.Add("", cdoSendUsingPort)
  12.                 msg.Fields.Add("", cdoBasic)
  13.                 msg.Fields.Add("", userName)
  14.                 msg.Fields.Add("", password)
  15.             End If
  16.             msg.[To] = ""
  17.             msg.From = ""
  18.             msg.Subject = "Subject"
  19.             msg.Body = "Message"
  20.             SmtpMail.SmtpServer = smtpServer
  21.             SmtpMail.Send(msg)
  22.         End Sub
Oct 18 '10 #6

P: 2
Thanks again for your reply.
I have one more bit of information:

When I run the 'snippet' on my machine the E-Mail ends-up in C:\Inetpub\mailroot\Queue with a name like NTFS-1234567abcde.EML
Double Click this and it opens in Outlook and can be 'Forwarded'.
There must be a difference between an E-Mail sent indirectly via SMTP and one sent directly via Outlook. I suspect this difference has something to do with 'authorisation' on my XP Mail Server.
I have E-Mailed and asked Microsoft if they have any comments as to why this has suddenly happened.
With luck this may result in them advising me that a recent Windows Update is the cause and, hopefully, providing a work-around.

David Smith
Oct 18 '10 #7

Post your reply

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