Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
This is my Default.aspx
 
<table>
    <tr>
    <td>
    Name
    </td>
    <td>
        <asp:TextBox ID="txtname" runat="server"></asp:TextBox>
    </td>
    </tr>
    <tr>
    <td>
    from
    </td>
    <td>
        <asp:TextBox ID="txtfrom" runat="server"></asp:TextBox>
    </td>
    </tr>
 
     <tr>
    <td>
    subject
    </td>
    <td>
        <asp:TextBox ID="txtsub" runat="server"></asp:TextBox>
    </td>
    </tr>
     <tr>
    <td>
    body
    </td>
    <td>
        <asp:TextBox ID="txtbody" runat="server"></asp:TextBox>
    </td>
    </tr>
     <tr>
    <td>
        <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    </td>
 
    </tr>
    </table><>
Default.aspx.cs
using System.Net.Mail;
protected void Button1_Click(object sender, EventArgs e)
    {
        SmtpClient mail = new SmtpClient();
        MailMessage msg = new MailMessage();
        string fromaddr = txtfrom.Text;
        msg.From = new MailAddress(fromaddr,txtname.Text);
 
        msg.To.Add("XXXXX@yahoo.com");
        msg.Subject = txtsub.Text;
        msg.IsBodyHtml = true;
        msg.Body = txtbody.Text;
        mail.Send(msg);
    }
Error: I am getting the error is Mailbox name not allowed. The server response was: Sorry, your envelope sender is in my badmailfrom list.
 

So, Please find a better solution and post a useful answer to me. this was an very urgent.
 

Thanks&Regards
 
Srikanth.J
 

[edit]Code blocks tidied up, urgency deleted: It may be urgent to you, but it isn't to us. All that your stressing the urgency does is to make us think you have left it too late, and want us to do it for you. This annoys some people, and can slow a response. - OriginalGriff[/edit]
Posted 24-May-11 21:57pm
Edited 24-May-11 22:04pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You can configure SMTP configuration in Web.Config like:
 <system.net>
    <mailSettings>
      <smtp from="abc@somedomain.com">
        <network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />
      </smtp>
    </mailSettings>
 </system.net>
 
If needed, have a look at this Microsoft Video tutorial:
Use ASP.NET to send Email from Website[^]
Tutorials on sending Email in ASP.NET[^]
  Permalink  
Comments
Espen Harlinn at 25-May-11 16:38pm
   
Good answer, simple and to the point - my 5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If your error is "Sorry, your envelope sender is in my badmailfrom list." then I would suggest you get your user to type something different into the textbox marked "From", and called "txtfrom".
 
There is a complete generic routine that sends email from ASP.NET here: Sending an Email in C# with or without attachments: generic routine.[^]
  Permalink  

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



Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 25 May 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100