Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello my friends .
i need the simple asp.net in c# code, where the visitors can send me email to my gmail account(or to my webmail of the domain name in the future), from my web site.

Where there are only Fullname TextBox, Email TextBox, Subject and Message TextBox.

No complications please please.

Thank you
Posted

Is it simple enough for you to use Google?

C# asp.net sendmail tutorial[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 28-Jun-11 21:06pm    
Yes, my 5.
--SA
put 3 text box , one for topic(subject), two for user`s email(from), three for description(body)
in code behind:
using System;
using System.Web.Mail;
in the button:
C#
protected void btn_send_Click(object sender, EventArgs e)
    {
        string smtpServer = "mail.mahsakashi.com";
        string userName = "info@mahsakashi.com";
        string password = "123";
        int cdoBasic = 1; //without changing
        int cdoSendUsingPort = 2; //without changing
        MailMessage msg = new MailMessage();
        if (userName.Length > 0)
        {
            msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer);
            msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25); //without changing
            msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort);
            msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic);
            msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", userName);
            msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password);
        }
        msg.To = "kashi_mahsa@yahoo.com";
        msg.From = "info@mahsakashi.com";
        msg.Subject = "Subject";
        msg.Body = "Message";
        SmtpMail.SmtpServer = smtpServer;
        SmtpMail.Send(msg);
    }
 
Share this answer
 
 
Share this answer
 
Comments
shantkh 28-Jun-11 17:20pm    
Hi Thanks for replay.
I Don't need the "TO" Section, when someone clicks send, i will receive his message to my email inbox.
In this example someone can send to another , not what i am looking for.
But anyway thank you very much, my friend.

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