Click here to Skip to main content
15,905,322 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm Making Contact US Page for our company site in asp.net .

my confige files code is Flollowing .
<configuration>

<system.web>
<customErrors mode="Off" defaultRedirect="mycustompage.htm"/>
</system.web>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="SomeWebsite Admin &lt;sales@precise&gt;">
<network host="mail.preciset" port="25" enableSsl="true" defaultCredentials="false"
userName="sales@pret.ca" password="secert" />
</smtp>
</mailSettings>
</system.net>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
And I've following Code in .cs files c# code 

SmtpClient smtp = new SmtpClient();
MailAddress to = new MailAddress("sales@precis.ca");
MailAddress from = new MailAddress(txtemail.Text);
MailMessage mail = new MailMessage(from, to);

mail.Body = "From:" + txtname.Text + "\n" + "Email: " + txtemail.Text + "\n" + " His Question: " + txtmsg.Text + "\n" + " Contact NO: " + txtcontact.Text;
try
{
smtp.Send(mail);

}

catch (Exception ex)
{

throw ex;
}

I'm using outlook ID and Passord . 

I getting this error 

*************************************************************************

Server Error in '/' Application.

Server does not support secure connections.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Net.Mail.SmtpException: Server does not support secure connections.

Source Error: 


Line 36:         {
Line 37: 
Line 38: throw ex; Line 39:         }
Line 40:     }

Source File: ContactUs.aspx.cs    Line: 38 

Stack Trace: 


[SmtpException: Server does not support secure connections.]
   Services.Button1_Click(Object sender, EventArgs e) in c:\HostingSpaces\ContactUs.aspx.cs:38
  
**************************************************************************

CSS
And when I  change a line in Config files, i put False  eg .(enableSsl="false")

Then i get Following Error :

Server Error in '/' Application.

Mailbox unavailable. The server response was: From address must match authenticated address

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Mail.SmtpException: Mailbox unavailable. The server response was: From address must match authenticated address

Source Error:


Line 36:         {
Line 37:
Line 38: throw ex; Line 39:         }
Line 40:     }


[SmtpException: Mailbox unavailable. The server response was: From address must match authenticated address]




I donot know is its Wrong with my outlook id and password?? if Outlook id and password problem,then what its would be ??
Please some one help me , give me solution , I've also post this Question in asp.net office site Furm but could not get help ..Hope from Codeproject 
Posted
Updated 14-Jul-13 21:54pm
v2

1 solution

MailAddress from = new MailAddress(txtemail.Text);
is wrong. The server cannot send an email on behalf of a foreign user - add the email address of the user contacting you somewhere in the email text.
The "form" part of the smtp configuration of your config file looks ok, but setting the from property manually overwrites that.
 
Share this answer
 
Comments
ShortProgrammer 21-Jul-13 12:57pm    
OH I am sorry i not understand this,If i change this then where user will put his Email address ??? maybe User Email id i take in body behind code from textbox??
I'm still confuse in "From" And "To" Part . in "form part which Id i'll put ??? my company Id?" and in "To" Part which i'll put ?/ in both same ??? here i confuse haha LOL
Thanks

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