0

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>");
2
Contributors
17
Replies
36
Views
3 Years
Discussion Span
Last Post by gahhon
0

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");
0

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

Edited by gahhon

0

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.

0

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

0

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

Sender = mailMessage.From
Recipeint = mailMessage.To

0
        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);

0

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?

0

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.

0

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

0

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

0

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.

Edited by JorgeM

0

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);
        }
0

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.

0

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

0

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.

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.