Mail message size problem (System.Web.Mail)

Discussion in 'Microsoft ASP .NET' started by Guest, Mar 14, 2005.

  1. Guest

    Guest 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;
    }
     
    Guest, Mar 14, 2005
    #1
    1. Advertisements

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. Guest

    System.Web.Mail.MailMessage - message size

    Guest, Sep 27, 2005, in forum: Microsoft ASP .NET
    Replies:
    0
    Views:
    247
    Guest
    Sep 27, 2005
  2. Brad
    Replies:
    2
    Views:
    1,138
  3. Guest

    System.Net.Mail vs System.Web.Mail

    Guest, Jun 16, 2006, in forum: Microsoft ASP .NET
    Replies:
    2
    Views:
    177
    Walter Wang [MSFT]
    Jun 16, 2006
  4. Nathan Sokalski

    Converting from System.Web.Mail to System.Net.Mail

    Nathan Sokalski, Dec 12, 2006, in forum: Microsoft ASP .NET
    Replies:
    5
    Views:
    161
    Spam Catcher
    Dec 12, 2006
  5. Nathan Sokalski
    Replies:
    5
    Views:
    884
    Gaurav Vaish \(www.Edujini-Labs.com\)
    Jan 10, 2007
Loading...

Share This Page