Jump to content

textbox para mail...


AKueda

Recommended Posts

boas pessoal...  😉

eu gostava de saber se alguém sabe como passa o texto k tenho nas caixas de texto num formulário para um mail...

tipo como nos fazemos para comentar num tópico ou mesmo fazer um novo tópico só k em vez da informação ir para uma base de dados, é mandado um mail com a informação k escrevemos, para um e-mail pré definido pelo responsável da pagina...

desde ja obrigado...

Link to comment
Share on other sites

public bool EnviarEmail(string mensagem, string assunto)
    {
        try
        {
            SmtpClient enviar = new SmtpClient();
            MailMessage msg = new MailMessage();
            msg.IsBodyHtml = true;
            enviar.Host = "servidor smtp";
            enviar.Port = 25;
            msg.From = new MailAddress("xpto@xpto.pt");
            msg.Subject = assunto;
            msg.Body = mensagem;
            msg.To = new MailAddress("para@xpto.pt");

            enviar.EnableSsl = ssl;

            if (credenciais)
            {
                enviar.Credentials = new System.Net.NetworkCredential(username, password);
            }

            enviar.Send(msg);
            return true;
        }
        catch
        {
            return false;
        }

    }

Aqui tens um exemplo. Muda-o ao  teu gosto.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.