Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Why the error is giving System.Runtime.InteropServices.COMException: The "SendUsing" configuration value is invalid.


SmtpMail.Send(msg);
Posted
Comments
jim lahey 31-Oct-11 5:26am    
post your code please
Janardan Pandey 31-Oct-11 5:30am    
<pre lang="HTML">

<html>
<body>



Email From ASP.NET



<form id="MailForm" method="post" runat="server">

<asp:Label ID="Label1" Style="left: 100px; position: absolute; top: 100px" runat="server">From:



<asp:TextBox ID="txtFrom" Style="left: 200px; position: absolute; top: 100px"

runat="server">

<asp:RequiredFieldValidator ID="FromValidator1" Style="left: 100px; position: absolute;

top: 375px" runat="server" ErrorMessage="Please Enter the Email From." Width="200px"

Height="23px" ControlToValidate="txtFrom">

<asp:RegularExpressionValidator ID="FromValidator2" Style="left: 100px; position: absolute;

top: 400px" runat="server" ErrorMessage="Please Enter a Valid From Email address"

ControlToValidate="txtFrom" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">

<asp:Label ID="Label2" Style="left: 100px; position: absolute; top: 125px" runat="server">To:



<asp:TextBox ID="txtTo" Style="left: 200px; position: absolute; top: 125px"

runat="server">

<asp:RequiredFieldValidator ID="ToValidator1" Style="left: 100px; position: absolute;

top: 425px" runat="server" ErrorMessage="Please Enter the Email To." Width="200px"

Height="23px" ControlToValidate="txtTo">

<asp:RegularExpressionValidator ID="ToValidator2" Style="left: 100px; position: absolute;

top: 450px" runat="server" ErrorMessage="Please Enter a Valid To Email address"

ControlToValidate="txtTo" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">

<asp:Label ID="Label3" Style="left: 100px; position: absolute; top: 150px"

runat="server">Subject

<asp:TextBox ID="txtSubject" Style="left: 200px; position: absolute; top: 150px"

runat="server">

<asp:Label ID="Label4" Style="left: 100px; position: absolute; top: 175px" runat="server">Mail:



<textarea runat="server" id="txtContent" style="left: 200px; width: 400px; position: absolute;

top: 175px; height: 125px" rows="7" cols="24">

</textarea>

<asp:Button ID="btnSend" Style="left: 200px; position: absolute; top: 350px" runat="server"

Text="Send" OnClick="btnSend_Click">

<asp:Label ID="lblStatus" Style="left: 250px; position: absolute; top: 350px" runat="server">



</form>

</body>

</html>
</pre>
<pre lang="c#">

<%@ Import Namespace="System.Web.Mail" %>
<%@ Page Language="C#" Debug="true" %>
<script runat="server">

private void btnSend_Click(object sender, System.EventArgs e)

{

MailMessage msg = new MailMessage();


msg.To = txtTo.Text;

msg.From = txtFrom.Text;

msg.Subject = txtSubject.Text;

msg.Body = txtContent.Value;
lblStatus.Text = "Sending...";


SmtpMail.Send(msg);

lblStatus.Text = "Sent email (" + txtSubject.Text + ") to " +txtTo.Text;

}

</script>
</pre>

1 solution

conifgure your smtp server setting on your machine.
 
Share this answer
 
Comments
Janardan Pandey 31-Oct-11 5:33am    
send mail through web mail server instead of smtp server

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900