Mail message size problem (System.Web.Mail)

G

Guest

I have a simple .Net console program that sends an email message. The
message can be specified as a string or a filename on the command line.
Refer to the code below.

The problem I am having is that it works fine on one computer (my
workstation) for messages of any size but it fails on another computer (my
test server) for messages larger than 900 bytes. Both systems are running
Windows 2003 Server - Standard Edition. My workstation is on a domain and
has Outlook installed. The test server is not on a domain and does not have
Outllook installed. The test involves sending directly to an external SMTP
server; I don't use the localhost for relaying.

The program will actually send messages from the test server if the body is
less than 900 bytes, however when i try to send a larger message, 1200 bytes,
it fails with the error:

Could not access 'CDO.Message' object.

Exception has been thrown by the target of an invocation.
The transport lost its connection to the server.

Does anyone have an idea about why there is a size limitation on one system
but no limitation on the other?


=====================================
THE CODE:

static public bool SendMessage(string strSubject, string strMsg,
string strFrom, string strTo, string strServer)
{
try
{
string strMsgBody = "";

if (strMsg.StartsWith("@"))
{
StreamReader rdr = new StreamReader(strMsg.Substring(1));
string sLine = rdr.ReadLine();
while (sLine != null)
{
strMsgBody += sLine + "\n";
sLine = rdr.ReadLine();
}

rdr.Close();
}
else
{
strMsgBody = strMsg;
}

System.Web.Mail.SmtpMail.SmtpServer = strServer;
System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage();

msg.From = strFrom;
msg.Subject = strSubject;
msg.Body = strMsgBody;
msg.BodyEncoding = System.Text.Encoding.ASCII;
msg.BodyFormat = MailFormat.Text;
msg.To = strTo;

System.Web.Mail.SmtpMail.Send(msg);
}
catch (Exception ex)
{
DumpException(ex);
return false;
}

return true;
}
 

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

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,739
Latest member
Clint8040

Latest Threads

Top