732d22f08a80a7b16757c3d9f59f5454

Recently i'm just created a new gmail account just for my project purpose.
But when i performing there is a feedback from end-users..
the email address of the sender is my new gmail account?

According to MailMessage MailMessage(SENDER, RECEIVER) am i right?
but how come i am can't display? @@

MailMessage mailMessage = new MailMessage(txtContactEmail.Text, "\"MSJ Bank Financial - Feedback & FAQ\" <mailmsj2013@gmail.com>");

I'm not following your description, but have you tried to set the to and from properties seperately.

For example...

mailMessage.From = new MailAddress("me@domain.com", "My Nice Display Name");
mailMessage.To.Add("destination@domain.com");
mailMessage.To.Add("anotherDestination@domain.com");

It still remain unchange. :/

    <system.net>
        <mailSettings>
            <smtp>
                <network host="smtp.gmail.com" userName="xxxx@gmail.com" password="xxxx" enableSsl="true" port="587"/>
            </smtp>
        </mailSettings>
    </system.net>

This is my web.config

The account you list in your web config is ONLY used for authenticating to gmail's SMTP server. It has nothing to do with the to or from addresses related to the message.

So I'm confused as to what issue you have.

The problem i have is i can't see what is the sender email...
It keep send from my email.

Sender email is: mailMessage.From = new MailAddress("me@domain.com", "My Nice Display Name")

Sender = mailMessage.From
Recipeint = mailMessage.To

        protected void ContactUs_Submit(object sender, EventArgs e)
        {
            MailMessage mailMessage = new MailMessage();
            mailMessage.From = new MailAddress(txtContactEmail.Text.ToString(), txtName.Text);
            mailMessage.To.Add(new MailAddress("mailmsj2013@gmail.com"));
            mailMessage.Subject = "Feedback/FAQ - " + txtName.Text;
            mailMessage.IsBodyHtml = true;
            mailMessage.Body = txtMessage.Text + "<br/><br/> Best Regards, <br/>" + txtName.Text;
            SmtpClient smtpClient = new SmtpClient();
            smtpClient.Send(mailMessage);
        }

75da0aeb4b8d43748567e955b429ef33

Now you see that picture that i highlighted.
mailMessage.From = new MailAddress( NOT DISPLAY, CORRECT);

Sorry, i'm not understanding...

are you saying that that Jack Wong is not the value that was stored in txtName.Text, and that the email address shown in your picture (which i cannot see) is not from txtContactEmail.Text?

the picture shown that
From: Jack Wong <mailmsj2013@gmail.com>
To: mailmsj2013@gmail.com

txtName.Text is correct, but the txtContactEmail.Text is wrong.
I had tried to run the project with the break point, and it able to read the value from txtContactEmail, but when showing in email inbox is wrong.

There's something else that's not right here. I dont know what though...

I just copied and pasted your code on my side and tested it. It works as expected.

Here is a screenshot of my code, settings, and results...

40aa74589c5479d90faaac8d77b648b6

According to your code and my code. Is totally the same, but why my one work incorrect one ? :o

Well, there seems to be something different that's not obvious. Here's is something to try that I do on occasion when I just cant seem to figure out what's going on.

Create a new Visual Studio project, and just add the web.config and that one aspx file. See if this issue is reproduced.

Try already, is remain the same. :/

web.config
  <system.net>
    <mailSettings>
      <smtp>
        <network host="smtp.gmail.com" userName="xxx@gmail.com" password="xxx" port="587" enableSsl="true" />
      </smtp>
    </mailSettings>
  </system.net>
.ASPX
        protected void Button1_Click(object sender, EventArgs e)
        {
            MailMessage mailMessage = new MailMessage();
            mailMessage.From = new MailAddress(TextBox1.Text.ToString(), TextBox2.Text);
            mailMessage.To.Add(new MailAddress("mailmsj2013@gmail.com"));
            mailMessage.Subject = "Feedback/FAQ - " + TextBox2.Text;
            mailMessage.IsBodyHtml = true;
            mailMessage.Body = "Testing";
            SmtpClient smtpClient = new SmtpClient();
            smtpClient.Send(mailMessage);
        }

The only thing that I can say is that it seems that you are typing: "mailmsj2013@gmail.com" in textbox1. If you are, that is why this is happening.

If not, then one line 4, remove the textbox1/textbox2 references and replace it with...

mailMessage.From = new MailAddress("otherEmail@somewhere.com", "Gahhon");

Other than that, I'm completely stumped.

Haha... I removed already but still can't work.
it still remain the same by displaying "mailmsj2013@gmail.com"..
So sad. :/

Sorry... i wish I could be of more help for you to solve this issue. I wrote up a sample and attached it to this post. I just tested it again and it works fine as expected. You simply need to update the smtp settings in the web.config file.

i am still unable to solve this problem? any one got the tricks?

Display the email address in the mail body.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.