| Author |
Message |
Guest
|
Posted:
Fri Sep 16, 2005 10:28 pm Post subject:
Mail sent using MailMessage class displays "TO" and "CC" rec |
|
|
I'm using System.Web.Mail to send an email message from an ASP.NET web
page.
This is the main section of the code.
//************* start code *****************************
string[] mailHost =
(System.Configuration.ConfigurationSettings.AppSettings.GetValues("mailserver"));
//Get data from page
string toAddress =
((tbTo.Text==null)||(tbTo.Text.Equals(String.Empty)))?String.Empty:tbTo.Text.Trim();
string ccAddress =
((tbCC.Text==null)||(tbCC.Text.Equals(String.Empty)))?String.Empty:tbCC.Text.Trim();
string subjectLine =
((tbSubject.Text==null)||(tbSubject.Text.Equals(String.Empty)))?String.Empty:tbSubject.Text.Trim();
string messageText =
((tbMessage.Text==null)||(tbMessage.Text.Equals(String.Empty)))?String.Empty:tbMessage.Text.Trim();
//Set message parameters
MailMessage MyMail = new MailMessage();
MyMail.From =
(System.Configuration.ConfigurationSettings.AppSettings.GetValues("fromaddress"))[0];
MyMail.To = toAddress;
MyMail.Cc = ccAddress;
MyMail.Subject = subjectLine;
MyMail.BodyFormat = MailFormat.Text;
MyMail.Body = messageText;
SmtpMail.SmtpServer = mailHost;
//send email
SmtpMail.Send(MyMail);
//************* end code *****************************
This code works perfectly when I send email to 5-10 users. However,
when I select a larger group of people the email gets jumbled up. It
puts all the "TO" addresses in the body of the message and also some
extraneous email header info (scroll down for more info). This software
I'm writing will be used to email hundreds of users on a daily basis.
Email message body looks like this for 5-10 users:
-------------------------------------------------
This is a test email. Please ignore and delete.
-------------------------------------------------
Email message body looks like this for a larger number of people
(a...@test.com is simply a dummy address I'm using for this posting):
-----------------------------------------------------
To:<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.c
om>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.
com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>
CC:<a...@test.com>
Subject: Test: Please ignore
Date: Fri, 16 Sep 2005 12:18:21 -0400
Message-ID: <00c101c5bada$4173eb80$0dfea8c0@odcisweb1>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181
Return-Path: webmas...@mycompany.com
X-OriginalArrivalTime: 16 Sep 2005 16:27:57.0147 (UTC)
FILETIME=[98A4D2B0:01C5BADB]
This is a test email. Please ignore and delete.
-----------------------------------------------
I cannot email such a large group of users again and again to find more
specifics. Please help. Why is my email not displaying the message
only? Why is it displaying all the recepients in the message body? Is
there a fix to this problem or do I have
|
|
| Back to top |
|
 |
Jason Johnston [MSFT]
Guest
|
Posted:
Thu Sep 22, 2005 12:59 am Post subject:
Re: Mail sent using MailMessage class displays "TO" and "CC" |
|
|
This sounds exactly like:
294379 Addressees Appear in Body of SMTP Message Instead of the Header If
You
http://support.microsoft.com/?id=294379
That's a bug we fixed in Windows 2000 SP3. I'm assuming that your SMTP
servers that relay this mail are all at or past that service pack?
<desi.american@gmail.com> wrote in message
news:1126891705.468346.239420@g47g2000cwa.googlegroups.com...
| Quote: | I'm using System.Web.Mail to send an email message from an ASP.NET web
page.
This is the main section of the code.
//************* start code *****************************
string[] mailHost =
(System.Configuration.ConfigurationSettings.AppSettings.GetValues("mailserver"));
//Get data from page
string toAddress =
((tbTo.Text==null)||(tbTo.Text.Equals(String.Empty)))?String.Empty:tbTo.Text.Trim();
string ccAddress =
((tbCC.Text==null)||(tbCC.Text.Equals(String.Empty)))?String.Empty:tbCC.Text.Trim();
string subjectLine =
((tbSubject.Text==null)||(tbSubject.Text.Equals(String.Empty)))?String.Empty:tbSubject.Text.Trim();
string messageText =
((tbMessage.Text==null)||(tbMessage.Text.Equals(String.Empty)))?String.Empty:tbMessage.Text.Trim();
//Set message parameters
MailMessage MyMail = new MailMessage();
MyMail.From =
(System.Configuration.ConfigurationSettings.AppSettings.GetValues("fromaddress"))[0];
MyMail.To = toAddress;
MyMail.Cc = ccAddress;
MyMail.Subject = subjectLine;
MyMail.BodyFormat = MailFormat.Text;
MyMail.Body = messageText;
SmtpMail.SmtpServer = mailHost;
//send email
SmtpMail.Send(MyMail);
//************* end code *****************************
This code works perfectly when I send email to 5-10 users. However,
when I select a larger group of people the email gets jumbled up. It
puts all the "TO" addresses in the body of the message and also some
extraneous email header info (scroll down for more info). This software
I'm writing will be used to email hundreds of users on a daily basis.
Email message body looks like this for 5-10 users:
-------------------------------------------------
This is a test email. Please ignore and delete.
-------------------------------------------------
Email message body looks like this for a larger number of people
(a...@test.com is simply a dummy address I'm using for this posting):
-----------------------------------------------------
To:<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test
.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@tes |
t.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>,<a...@test.com>
| Quote: | CC:<a...@test.com
Subject: Test: Please ignore
Date: Fri, 16 Sep 2005 12:18:21 -0400
Message-ID: <00c101c5bada$4173eb80$0dfea8c0@odcisweb1
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181
Return-Path: webmas...@mycompany.com
X-OriginalArrivalTime: 16 Sep 2005 16:27:57.0147 (UTC)
FILETIME=[98A4D2B0:01C5BADB]
This is a test email. Please ignore and delete.
-----------------------------------------------
I cannot email such a large group of users again and again to find more
specifics. Please help. Why is my email not displaying the message
only? Why is it displaying all the recepients in the message body? Is
there a fix to this problem or do I have
|
|
|
| Back to top |
|
 |
Jason Johnston [MSFT]
Guest
|
Posted:
Fri Sep 23, 2005 12:58 am Post subject:
Re: Mail sent using MailMessage class displays "TO" and "CC" |
|
|
Ok..interestingly enough I can send to 1001 recipients on the To: line
through my Exchange 2003/Windows 2003 server just fine. No bleeding over of
the recips into the body. I sent it to a user with a mailbox on that
server, and I'm reading it with OWA...not sure if that's what you're doing
or not.
<desi.american@gmail.com> wrote in message
news:1127424883.573192.72130@z14g2000cwz.googlegroups.com...
| Quote: | Hi,
C# Code for email is listed in the first message. The server is
Exchange Server 2003 on Windows 2003. If it will help you, I can paste
the script for a SQL Server stored procedure I use alternatively.
Stored proc or C# code, emailing many users will cause the above
problem.
This happens only when I email a larger group of people. I'm guessing
here but the magic number of recepients is 25-30 or greater. Either
that or the number of characters in the "To:" fields exceeds some magic
number between 800-1000.
I can comfortably send emails to smaller groups (5-15 recepients) and
the email formatting is not affected at all.
|
|
|
| Back to top |
|
 |
Guest
|
Posted:
Fri Sep 23, 2005 12:58 am Post subject:
Re: Mail sent using MailMessage class displays "TO" and "CC" |
|
|
Hi,
C# Code for email is listed in the first message. The server is
Exchange Server 2003 on Windows 2003. If it will help you, I can paste
the script for a SQL Server stored procedure I use alternatively.
Stored proc or C# code, emailing many users will cause the above
problem.
This happens only when I email a larger group of people. I'm guessing
here but the magic number of recepients is 25-30 or greater. Either
that or the number of characters in the "To:" fields exceeds some magic
number between 800-1000.
I can comfortably send emails to smaller groups (5-15 recepients) and
the email formatting is not affected at all. |
|
| Back to top |
|
 |
Jason Johnston [MSFT]
Guest
|
Posted:
Fri Sep 23, 2005 12:58 am Post subject:
Re: Mail sent using MailMessage class displays "TO" and "CC" |
|
|
None that I'm aware of.
Does this happen for all your recipients or just some? If just some, what
kind of e-mail server are they running?
If I were to try to reproduce this, what would be the steps?
<desi.american@gmail.com> wrote in message
news:1127422690.248180.238200@g44g2000cwa.googlegroups.com...
| Quote: | Jason,
Thanks for the reply. We are using Windows 2003 servers for the SMTP
servers. Are there any particular hotfixes in Win2003 for the same
issue?
|
|
|
| Back to top |
|
 |
Guest
|
Posted:
Fri Sep 23, 2005 12:58 am Post subject:
Re: Mail sent using MailMessage class displays "TO" and "CC" |
|
|
The stored proc:
CREATE PROCEDURE dbo.s_Notification_Email
@To ntext,
@CC ntext,
@Body ntext,
@Subject nvarchar(4000)
AS
Declare @iMsg int
Declare @hr int
Declare @source varchar(255)
Declare @description varchar(500)
Declare @output varchar(1000)
--************* Create the CDO.Message Object ************************
EXEC @hr = sp_OACreate 'CDO.Message', @iMsg OUT
--***************Configuring the Message Object ******************
-- This is to configure a remote SMTP server.
--
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_schema_configuration_sendusing.asp
EXEC @hr = sp_OASetProperty @iMsg,
'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendusing").Value','2'
-- This is to configure the Server Name or IP address.
-- Replace MailServerName by the name or IP of your SMTP Server.
EXEC @hr = sp_OASetProperty @iMsg,
'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value',
'mail.company.com'
-- Save the configurations to the message object.
EXEC @hr = sp_OAMethod @iMsg, 'Configuration.Fields.Update', null
-- Set the e-mail parameters.
EXEC @hr = sp_OASetProperty @iMsg, 'To', @To
EXEC @hr = sp_OASetProperty @iMsg, 'CC', @CC
EXEC @hr = sp_OASetProperty @iMsg, 'From', 'webmaster@company.com'
EXEC @hr = sp_OASetProperty @iMsg, 'Subject', @Subject
-- If you are using HTML e-mail, use 'HTMLBody' instead of 'TextBody'.
EXEC @hr = sp_OASetProperty @iMsg, 'HTMLBody', @Body
EXEC @hr = sp_OAMethod @iMsg, 'Send', NULL
-- Sample error handling.
IF @hr <>0
select @hr
BEGIN
EXEC @hr = sp_OAGetErrorInfo NULL, @source OUT, @description OUT
IF @hr = 0
BEGIN
SELECT @output = ' Source: ' + @source
PRINT @output
SELECT @output = ' Description: ' + @description
PRINT @output
END
ELSE
BEGIN
PRINT ' sp_OAGetErrorInfo failed.'
RETURN
END
END
-- Do some error handling after each step if you need to.
-- Clean up the objects created.
EXEC @hr = sp_OADestroy @iMsg |
|
| Back to top |
|
 |
Guest
|
Posted:
Fri Sep 23, 2005 12:58 am Post subject:
Re: Mail sent using MailMessage class displays "TO" and "CC" |
|
|
Jason,
Thanks for the reply. We are using Windows 2003 servers for the SMTP
servers. Are there any particular hotfixes in Win2003 for the same
issue? |
|
| Back to top |
|
 |
Guest
|
Posted:
Fri Sep 23, 2005 4:58 pm Post subject:
Re: Mail sent using MailMessage class displays "TO" and "CC" |
|
|
The web server on which the email code resides, the SQL Server which
executes the email stored procedure and the SMTP server are 3 seperate
Windows 2003 server boxes within the intranet. If that does not make it
more complex, the emails are sent to different clients in different
organizations. Most of them use Outlook but some of them are also using
web based email clients like Yahoo and GMail. |
|
| Back to top |
|
 |
Jason Johnston [MSFT]
Guest
|
Posted:
Fri Sep 23, 2005 4:58 pm Post subject:
Re: Mail sent using MailMessage class displays "TO" and "CC" |
|
|
Hmm...I don't know what MailMax Pro is, but it may be key to reproducing
this.
<desi.american@gmail.com> wrote in message
news:1127488285.004625.26870@g14g2000cwa.googlegroups.com...
| Quote: | The web server and database server are Win 2003 boxes and they are not
yet updated with SP1. Red-tape there.
Also let me backtrack some here. I just got word from the system admin
guys that the email server is a Windows 2000 box running MailMax Pro.
This box is updated with SP4 for Win2000.
Sorry for the confusion caused earlier but I can just go by what I was
told by the system admin guys.
|
|
|
| Back to top |
|
 |
Jason Johnston [MSFT]
Guest
|
Posted:
Fri Sep 23, 2005 4:58 pm Post subject:
Re: Mail sent using MailMessage class displays "TO" and "CC" |
|
|
Hmm..odd that I cannot reproduce it. Is your SMTP server an Exchange
server? Do you have Windows 2003 SP1 applied to the SMTP server?
<desi.american@gmail.com> wrote in message
news:1127481654.358111.254240@g44g2000cwa.googlegroups.com...
| Quote: | The web server on which the email code resides, the SQL Server which
executes the email stored procedure and the SMTP server are 3 seperate
Windows 2003 server boxes within the intranet. If that does not make it
more complex, the emails are sent to different clients in different
organizations. Most of them use Outlook but some of them are also using
web based email clients like Yahoo and GMail.
|
|
|
| Back to top |
|
 |
Guest
|
Posted:
Fri Sep 23, 2005 4:58 pm Post subject:
Re: Mail sent using MailMessage class displays "TO" and "CC" |
|
|
The web server and database server are Win 2003 boxes and they are not
yet updated with SP1. Red-tape there.
Also let me backtrack some here. I just got word from the system admin
guys that the email server is a Windows 2000 box running MailMax Pro.
This box is updated with SP4 for Win2000.
Sorry for the confusion caused earlier but I can just go by what I was
told by the system admin guys. |
|
| Back to top |
|
 |
Guest
|
Posted:
Fri Sep 23, 2005 4:58 pm Post subject:
Re: Mail sent using MailMessage class displays "TO" and "CC" |
|
|
The web server and database server are Win 2003 boxes and they are not
yet updated with SP1. Red-tape there.
Also let me backtrack some here. I just got word from the system admin
guys that the email server is a Windows 2000 box running MailMax Pro.
This box is updated with SP4 for Win2000.
Sorry for the confusion caused earlier but I can just go by what I was
told by the system admin guys. |
|
| Back to top |
|
 |
|
|
|
|