Mail.SmtpClient sending duplicates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I tried out the new System.Net.Mail.SmtpClient feature of asp.net 2.0 and I
love it, but there's just one problem. When it sends an email out, it sends
to BOTH the TO and the FROM address. I have the following code which is very
simple.

------------------------snip----------------------------------
Dim client = New System.Net.Mail.SmtpClient("mail.mydomain.net")
client.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
lsEmailSubj = "test1"
lsEmailBody = "test2"
Dim msgmail As New
System.Net.Mail.MailMessage("(e-mail address removed)",
"(e-mail address removed)", lsEmailSubj, lsEmailBody)
client.Send(msgmail)
--------------------------------------------------------------

This is the only part of my code that actually sends out the email and the
TO and FROM are hardcoded as you can see. However, TWO emails get sent out.
One is from globalitreporting, to user1 .. and... then it sends out the
second email FROM globalitreporting TO globalitreporting.

The really strange thing is that this only happens SOMETIMES, maybe 1/3 of
the time. Is there something about the SmtpClient class that I am forgetting
or is there some setting on my SMTP server that might be messing this up?

Does anyone have any ideas? ;)

->Brian Lorraine
 
I have some email send code at my blog
spaces.msn.com/sholliday/
and i have never gotten a duplicate.


there is 1.1 and 2.0 code there.

I am not using an overloaded constructor like you are , fyi.
 
Brian Lorraine said:
I tried out the new System.Net.Mail.SmtpClient feature of asp.net 2.0 and I
love it, but there's just one problem. When it sends an email out, it
sends
to BOTH the TO and the FROM address. I have the following code which is
very
simple.

------------------------snip----------------------------------
Dim client = New System.Net.Mail.SmtpClient("mail.mydomain.net")
client.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
lsEmailSubj = "test1"
lsEmailBody = "test2"
Dim msgmail As New
System.Net.Mail.MailMessage("(e-mail address removed)",
"(e-mail address removed)", lsEmailSubj, lsEmailBody)
client.Send(msgmail)
--------------------------------------------------------------

This is the only part of my code that actually sends out the email and the
TO and FROM are hardcoded as you can see. However, TWO emails get sent
out.
One is from globalitreporting, to user1 .. and... then it sends out the
second email FROM globalitreporting TO globalitreporting.

The really strange thing is that this only happens SOMETIMES, maybe 1/3 of
the time. Is there something about the SmtpClient class that I am
forgetting
or is there some setting on my SMTP server that might be messing this up?

Does anyone have any ideas? ;)

->Brian Lorraine
Maybe something in you code is causing this process to run twice. How is it
called.?
 
The code running twice wouldn't explain the email being sent both to the
TO and FROM addresses.
 
Back
Top