complex error sending HTML email using system.web.mail

I am getting following error while trying to send HTML email trough my code(I am using system.web.mail). I have mailenable enterprise edition installed on my server.

I have window application which can successfully send HTML emails for most of the emails. But for some emails only i am getting following exception.

Exception : Unknown Error
Stack Trace : at System.Web.Mail.SmtpMail.LateBoundAccessHelper.SetProp(Object obj, String propName, Object propValue)
   at System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMessage message)
   at System.Web.Mail.SmtpMail.Send(MailMessage message)
   at Scheduler.MainScheduler.main() in E:\Projects\KG\scheduler\MainScheduler.vb:line 620

Inner Exception
: Exception has been thrown by the target of an invocation.
Inner Exception stack trace: at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.Web.Mail.SmtpMail.LateBoundAccessHelper.SetProp(Type type, Object obj, String propName, Object propValue)
   at System.Web.Mail.SmtpMail.LateBoundAccessHelper.SetProp(Object obj, String propName, Object propValue)

Can anybody help me to find out problem? Is it related to outbound size of email? Whats the default outboud email size in mailenable enterprise edition? I have the "Limit outbound message size" checkbox is unchecked.

7/16/2008 7:56:50 AM 91979 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 55

check these links for sending mail


2.Using ASP.NET to Send E-Mail—Including Attachments -


4.How to configure an Internet Information Services SMTP virtual server to archive or to remove messages in an Exchange Server 2003 test environment

5.Sending HTML Mail with Embedded Image in .NET _Embedded_Image_in_NET.all



try this example:

create class in App_Code


using System.Net.Mail;

public class MailHelper
    /// <summary>
    /// Sends an mail message
    /// </summary>
    /// <param name="from">Sender address</param>
    /// <param name="to">Recepient address</param>
    /// <param name="bcc">Bcc recepient</param>
    /// <param name="cc">Cc recepient</param>
    /// <param name="subject">Subject of mail message</param>
    /// <param name="body">Body of mail message</param>
    public static bool SendMailMessage(string from, string to, string bcc, string cc, string subject, string body)
        // Instantiate a new instance of MailMessage
        MailMessage mMailMessage = new MailMessage();

        // Set the sender address of the mail message
        mMailMessage.From = new MailAddress(from);
        // Set the recepient address of the mail message
        mMailMessage.To.Add(new MailAddress(to));

        // Check if the bcc value is null or an empty string
        if ((bcc != null) && (bcc != string.Empty))
            // Set the Bcc address of the mail message
            mMailMessage.Bcc.Add(new MailAddress(bcc));

        // Check if the cc value is null or an empty value
        if ((cc != null) && (cc != string.Empty))
            // Set the CC address of the mail message
            mMailMessage.CC.Add(new MailAddress(cc));

        // Set the subject of the mail message
        mMailMessage.Subject = subject;
        // Set the body of the mail message
        mMailMessage.Body = body;

        // Secify the format of the body as HTML
        mMailMessage.IsBodyHtml = true;
        // Set the priority of the mail message to normal
        mMailMessage.Priority = MailPriority.Normal;

        // Instantiate a new instance of SmtpClient
        SmtpClient mSmtpClient = new SmtpClient();
        // Send the mail message
        return true;

create Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
        <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
            <asp:View ID="View1" runat="server">
                <table style="width: 308px">
                            <asp:TextBox ID="txt_To" runat="server"></asp:TextBox></td>
                            Your Email:</td>
                            <asp:TextBox ID="txt_From" runat="server"></asp:TextBox></td>
                            <asp:TextBox ID="txt_CC" runat="server"></asp:TextBox></td>
                            <asp:TextBox ID="txt_Subject" runat="server"></asp:TextBox></td>
                            <asp:TextBox ID="txt_Message" runat="server" TextMode="MultiLine"></asp:TextBox></td>
                        <td style="text-align: right">
                            <asp:Button ID="Button1" runat="server" Font-Bold="True" OnClick="Button1_Click"
                                Text="Send" /></td>
            <asp:View ID="View2" runat="server">
                <br />
                Thank You
                <br />
                <br />
                Your Email has been sent<br />
                <br />
            <asp:View ID="View3" runat="server">
                <br />
                An Error accured during sending email<br />
                <br />
                <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">here</asp:LinkButton>
                to try again.<br />


and in code behind:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        Button1.Attributes.Add("onclick"," = 'wait'; this.value='Please wait...'; this.disabled = true; " + this.GetPostBackEventReference(Button1, string.Empty) + ";");


    protected void Button1_Click(object sender, EventArgs e)
        bool x = MailHelper.SendMailMessage(txt_From.Text, txt_To.Text, "", txt_CC.Text, txt_Subject.Text, txt_Message.Text);
        if (x == true)
            MultiView1.ActiveViewIndex = 1;
            MultiView1.ActiveViewIndex = 2;

    protected void LinkButton1_Click(object sender, EventArgs e)
        MultiView1.ActiveViewIndex = 0;


and in web.config

      <smtp from="your email">
        <network host="your smtp" port="25" userName="your email" password="xxxxxx"/>

Good Luck

7/16/2008 5:27:54 PM


I know how to send emails, infact i have used all the techniques you described. The problem is some HTML emails are being send successfully by same code whereas for very few emails i am getting the exceptions i described in my first post.

I want to know abt the Exception, Can you explain me this exception please. Why is it throwing? Whts the cause of this exception.


7/17/2008 4:29:01 AM

Can you check what kind of HTML emails when you try to send in email throw exception? After sorting them out may be resolve your problem.


if (myReply.Equals(YourAnswer))
MarkThisThread = "Answerd";
7/17/2008 4:41:36 AM

Solution for e-mail related errors :

7/17/2008 4:57:00 AM

Similar Artilces:

Sending Email through System.Net.Mail is generating errors "Failure Sending mail
hi Sending Email through System.Web.Mail is working fine but System.Net.Mail is generating errors "Failure Sending mail  i treid in all possible ways but did't  pls help in giving a solution thanks & Regards vittal Maybe you can show us some code and post the exact error mesg as well (by looking at the value in ex.tostring)?My HomePage -"It is more blessed to give than to receive." Acts 20: 35 (NIV, Bible)Progress - "Never discourage anyone...who continually makes progress, no matter how slow." Plato System.Web.Ma...

Why do Sending SMTP Authenticated E-mail succeed using SmtpMail.Send() function but fail using SmtpClient.send() function ? Bugs in System.Net.Mail.SmtpClient when send a Authenticated E-mail?
I click btnOK button, the email can send OK, but click btnFail button,  the following error is displayed! why ? you can test the section code. The SMTP, username, password are valid!  Many thanks! "Syntax error, command unrecognized. The server response was: authentication failed,decode user password error" I have tested some other SMTP, somes is OK. I think there are some bugs with System.Net.Mail.SmtpClient when send a Authenticated E-mail with some SMTP!   //------------------------------------------.ASPX Code----------------------------------------...

Sending Email using HTML file as Emailbody using Net.Mail.MailMessage... Please help
Hi all I can send emails with text or html emailbody using, but cannot find any method or example so far on the web to show how to use an html file as an emailbody. I have tried everything. I know how to do it with the old asp. I have created a html document for example newsletter.html. I want this document to be in the email body when the client opens the email. It must not load from another url. I suppose what i want to do is embed it into the email.Any help or examples will be appreciated as this is quite urgent for me to implement it for my client.  This is the code im ...

HOW TO: Send email using System.Net.Mail
 Looks like they locked the thread in the FAQ section, so I'll just ask my question here. I"m using a version of the System.Net.Mail class that was posted in the FAQ section. I'm trying to use it like this:            string from = EmailTextBox.Text;            string to = ContactIdentifier.EmailAddress;            string bcc = "";            strin...

Sending email using
 I am trying to send email using Asp .Net. I am using System.Net.Mail namespace. The code i written is below MailMessage message = new MailMessage(); message.From = new MailAddress(""); message.To.Add(new MailAddress("")); message.Subject = "Test"; message.Body = "This is a test message"; message.IsBodyHtml = false; SmtpClient mailClient = new SmtpClient("", 587); mailClient.Credentials = ne...

Send email using System.Net.Mail
hi to all,  while i am sending mail to gmail ,i am facing problem.but i can send mail to other smtp adress like( give advice how to send email to gmail(i didn't give any details other than  below code).thank you in advance.   protected void btnSubmit_Click(object sender, EventArgs e)        {                                     &nbs...

HOW TO: Send email using System.Net.Mail
Below is a C# and VB.NET class that demonstrates using System.Net.Mail to send an email. Download C# System.Net.Mail HelperDownload VB.NET System.Net.Mail Helper Calling the function from code MailHelper.SendMailMessage("", "", "", "", "Sample Subject", "Sample body of text for mail message") MailHelper.cs using System.Net.Mail; public class MailHelper{   /// <summary>   /// Sends an mail ...

Sending Mail Using System.Net.Mail with out using User credentials
HI, I have an application where in i send mails based on some condition, the user is already authenticated, so i need not check the User Credentials.Right now this is how the piece lokks:- mailClient.Credentials = new NetworkCredential(USERID, USER_PWD,DOMAIN); I want to send the mail, with out validating the user credentials, Can i skip the above line. Please post aqlong with the sample code.   Thanx in Advance. Anil Kumar.   I think you cannot skip. but store user credentials in session variables after login and then pass.If this post was useful to you, please mark it as...

Aspose.Email 1.1 Released!
Aspose.Email 1.1 Released! Version 1.1.0 Released on January 25 2005 ...

Problem with difference between System.Web.Mail and System.Net.Mail in using attachments
I have a web .Net app which sends emails with attachments.  After the email is sent I clean up aftermyself and delete the attachments from disk.   In upgrading to .Net 2  I changed the email logic from using system.web.mail to  (of course vs is telling me system.web.mail is obsolete).In .Net 1.1,  the files deleted with no problem but in .Net 2 when I attempt to delete  I receive The process cannot access the file ...' because it is being used by another process. If I change the code back to using system.web.mail I can delete the file...

What additional advantage we get through over the old system.web.mail?
What additional advantage we get through over the old system.web.mail?Is it needed to configure the smtp server? Plz tell me the steps to develop the email sending facility in our applicationSwati Jain Take a look at Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue....

Send Email from form using
Please see code behind below. This my message is being received by only with hard coded text of subject with no body.  How do I correct my syntax so that the information is passed from form fields to email message?  The form data is being inserted into the db and redirected to .aspx page.  Just need to get data from for fields to message.  -------------------------------------------- Imports System.Net.MailPartial Class apps_contactpage Inherits System.Web.UI.PageSub Send2Mail(ByVal sender As Object, ByVal e As FormViewInsertedEventArgs) 'create the mail...

Problem on Sending email using System.Web.Mail
Imports System.Web.Mail Dim WelcomeMsg As New MailMessage WelcomeMsg.To = txtEmail.Text WelcomeMsg.From = "NNN" WelcomeMsg.Subject = "Welcome you" WelcomeMsg.Priority = MailPriority.High WelcomeMsg.Body = "hellloooooooo" SmtpMail.Send(WelcomeMsg) I got the following error msg: "Could not access 'CDO.Message' object. " anyone know whats going on? Thanks Do you have SMTP ...

Problems sending emails using System.Web.Mail
Hi, I am trying to send emails using System.Web.Mail. Here is what I am trying to do MailMessage Message = new MailMessage(); Message.To = ""; Message.From = ""; Message.Subject = "Test Mail"; Message.Body = "Test Message"; SmtpMail.Send(Message); I am not getting any error message but its not firing any emails either. Any ideas? help please! Thanks! I got it working!!!...

Web resources about - complex error sending HTML email using system.web.mail -

Complex - Style, Music, Sneakers, Entertainment, Girls, Technology
Complex Magazine: The original buyer's guide for men.

Multiprotein complex - Wikipedia, the free encyclopedia
A multiprotein complex (or protein complex ) is a group of two or more associated polypeptide chains. If the different polypeptide chains contain ...

Complex Regional Pain Syndrome: CPRS researchers study auditory connection
For 16 years Kerry Whyman ``secretly&quot; thought she had bone cancer and was dying secretly because she'd stopped telling doctors how much ...

Fire Damages Lancaster Apartment Complex
A 36-unit apartment complex had to be evacuated, Sunday morning, after a fire started on the second story of the three-story building.

South Sudan: The complex factors of famine
Millions go hungry as El Nino, price hikes, and conflict combine to steer South Sudan towards starvation.

Shadow Complex Remastered out early next year, but you can download it free on PC right now
Shadow Complex is finally getting that remaster everyone sorta expected. Woo-hoo! I remember enjoying it back when it was an Xbox 360 exclusive, ...

OMA completes pixellated Timmerhuis complex in Rotterdam
OMA has merged a municipal office block from the 1950s with a pixellated steel and glass structure to create the mixed-use Timmerhuis complex ...

Time Travel Could Solve Complex Math Problems
A theoretical computing system could propel information through the very fabric of space-time.

Bill And Melinda Gates Brilliantly Explain Complex Stuff In Simple Words
I’ve often said that a person can have a great idea, but if that person cannot persuade others then it doesn’t matter. Bill and Melinda Gates ...

Gene Editing Won't Work on Complex Traits Like Intelligence
As we consider the ethics of human gene editing, we need to understand what can and can’t be meaningfully edited. Read more...

Resources last updated: 12/24/2015 6:29:59 AM