Пример #1
0
        private void btnEnviar_Click(object sender, EventArgs e)
        {
            try
            {
                int ret = ACBrMail.MAIL_Clear();
                ACBrMail.CheckResult(ret);

                ret = ACBrMail.MAIL_AddAddress(txtDestinatario.Text.ToUTF8(), txtDestinatario.Text.ToUTF8());
                ACBrMail.CheckResult(ret);

                ret = ACBrMail.MAIL_SetSubject(txtAssunto.Text.ToUTF8());
                ACBrMail.CheckResult(ret);

                ret = ACBrMail.MAIL_AddBody(txtBody.Text.ToUTF8());
                ACBrMail.CheckResult(ret);

                ret = ACBrMail.MAIL_AddAltBody(txtAltBody.Text.ToUTF8());
                ACBrMail.CheckResult(ret);

                foreach (String anexo in lstAnexos.Items)
                {
                    ret = ACBrMail.MAIL_AddAttachment(anexo, anexo, 0);
                    ACBrMail.CheckResult(ret);
                }

                ret = ACBrMail.MAIL_Send();
                ACBrMail.CheckResult(ret);

                MessageBox.Show("Email enviado com sucesso!", "ACBrMail - Demo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao enviar email: " + ex.Message.ToString(), "ACBrMail - Demo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }