Update on system.net.mail behaviour I think this is important.

B

Bob

Vs2005 - Framework2. Just to let all of you know. I have found that I can
not use an application to send e-mails using the system,net.mail namespace
while Outlook express is opened on the same machine from which my program is
trying to send an e-mail using smtp mail set to the same smtp server account
as the currently selected outlook mail account. (code snippet follows at
end) the application just does not send e-mail and no exception is
generated.

I started a new thread on this because if what I detected is true it may be
critical to many apps and I want to bring this to your attention.

If this is indeed the case it has some serious implications that warrant
looking into by MS. Say you have a service running that is sending e-mails
of warnings of critical events in certain apps on your computer and it is
configured to use the same smtp account as your outlook. This would mean
that your service would not be sending these notifications if your outlook
is open on the sending computer and there's no way you would know.
Definitely not good behaviour.

Has anyone else noted something similar. If it works Ok for you while
outlook is open what is different in your code from mine?

This is the code being used on a form with just one button to test it. All
it does is send an e-mail from me to myself. The smtp server is not
colocated on my computer but is hosted by a provider outside my LAN. The
smtp service is running on my local host and I have an instance of IIS used
for testing on my local host. I don't know if the above influences anything.
I do know that in Vs2003 when I used system.web.mail to send e-mails I
needed to have IIS running and did not encounter this type of problem. But
since MS deprecated the system.web.mail I thought I'd go with the flow. Not
sure it was a good idea <GGGG>. Anyways, here's the snippet.

Please test it and let me know if you encounter the same situation.
Imports System.net.mail 'before class declaration
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim message As New MailMessage()
Try
message.From = New MailAddress("(e-mail address removed)")
message.To.Add(New MailAddress("(e-mail address removed)"))
message.Subject = "Test"
message.Body = "Test body"
Dim Client As New SmtpClient()
Client.Host = "mail.mydomain.com"
Client.Port = 25
Dim LoginCredentials As New
System.Net.NetworkCredential("(e-mail address removed)", "mypassword")
Client.UseDefaultCredentials = False
Client.Credentials = LoginCredentials
Client.Send(message)
Catch ex As SmtpException
MsgBox(ex.Message)
End Try
End Sub

Thanks to all

Bob
 
B

Bob

Sorry I said Outlook express, weas mistake. Am using Outlook 2003. Rest all
same
Fingers tired
Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top