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

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

P: n/a
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("my****@mydomain.com")
message.To.Add(New MailAddress("my****@mydomain.com"))
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("my****@mydomain.com" , "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


Feb 1 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Bob
Sorry I said Outlook express, weas mistake. Am using Outlook 2003. Rest all
same
Fingers tired
Bob
"Bob" <bd*****@sgiims.com> wrote in message
news:eV*************@TK2MSFTNGP15.phx.gbl...
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("my****@mydomain.com")
message.To.Add(New MailAddress("my****@mydomain.com"))
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("my****@mydomain.com" , "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

Feb 1 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.