Mail message size problem (System.Web.Mail)

Discussion in 'ASP .Net' started by =?Utf-8?B?TXJGZXo=?=, Mar 14, 2005.

  1. 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;
    }
     
    =?Utf-8?B?TXJGZXo=?=, Mar 14, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bWc=?=

    Size of e-mail message - message.Body = msgText

    =?Utf-8?B?bWc=?=, Feb 10, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    599
    Chad Z. Hower aka Kudzu
    Feb 11, 2004
  2. =?Utf-8?B?Qm9i?=

    System.Web.Mail.MailMessage - message size

    =?Utf-8?B?Qm9i?=, Sep 27, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    467
    =?Utf-8?B?Qm9i?=
    Sep 27, 2005
  3. Brad
    Replies:
    2
    Views:
    11,269
  4. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    System.Net.Mail vs System.Web.Mail

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, Jun 16, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    10,670
    Walter Wang [MSFT]
    Jun 16, 2006
  5. Nathan Sokalski
    Replies:
    5
    Views:
    958
    Spam Catcher
    Dec 12, 2006
Loading...

Share This Page